use Symfony\Component\HttpFoundation\Request;
use Wallabag\CoreBundle\Repository;
use Wallabag\CoreBundle\Entity\Entries;
-use Wallabag\Wallabag\Tools;
-use Wallabag\Wallabag\Url;
+use Wallabag\CoreBundle\Service\Extractor;
+use Wallabag\CoreBundle\Helper\Url;
class EntryController extends Controller
{
-
/**
- * @param Request $request
+ * @param Request $request
* @Route("/new", name="new_entry")
* @return \Symfony\Component\HttpFoundation\Response
*/
$form->handleRequest($request);
if ($form->isValid()) {
+ $content = Extractor::extract($entry->getUrl());
- $content = Tools::getPageContent(new Url($entry->getUrl()));
- var_dump($content);die;
+ $entry->setTitle($content->getTitle());
+ $entry->setContent($content->getBody());
- $em = $this->getDoctrine()->getEntityManager();
+ $em = $this->getDoctrine()->getManager();
$em->persist($entry);
$em->flush();
public function showUnreadAction()
{
$repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entries');
+ // TODO don't give the user ID like this
+ // TODO change pagination
$entries = $repository->findUnreadByUser(1, 0);
return $this->render(
public function showArchiveAction()
{
$repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entries');
+ // TODO don't give the user ID like this
+ // TODO change pagination
$entries = $repository->findArchiveByUser(1, 0);
return $this->render(
public function showStarredAction()
{
$repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entries');
+ // TODO don't give the user ID like this
+ // TODO change pagination
$entries = $repository->findStarredByUser(1, 0);
return $this->render(
/**
* Shows entry content
*
- * @param Entries $entry
+ * @param Entries $entry
* @Route("/view/{id}", requirements={"id" = "\d+"}, name="view")
* @return \Symfony\Component\HttpFoundation\Response
*/
/**
* Changes read status for an entry
*
- * @param Request $request
- * @param Entries $entry
+ * @param Request $request
+ * @param Entries $entry
* @Route("/archive/{id}", requirements={"id" = "\d+"}, name="archive_entry")
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
/**
* Changes favorite status for an entry
*
- * @param Request $request
- * @param Entries $entry
+ * @param Request $request
+ * @param Entries $entry
* @Route("/star/{id}", requirements={"id" = "\d+"}, name="star_entry")
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
/**
* Deletes entry
*
- * @param Request $request
- * @param Entries $entry
+ * @param Request $request
+ * @param Entries $entry
* @Route("/delete/{id}", requirements={"id" = "\d+"}, name="delete_entry")
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function deleteEntryAction(Request $request, Entries $entry)
{
- $em = $this->getDoctrine()->getEntityManager();
+ $em = $this->getDoctrine()->getManager();
$em->remove($entry);
$em->flush();