diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/SecurityController.php | 27 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/WallabagRestController.php | 9 |
2 files changed, 32 insertions, 4 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/SecurityController.php b/src/Wallabag/CoreBundle/Controller/SecurityController.php new file mode 100644 index 00000000..51f9cc26 --- /dev/null +++ b/src/Wallabag/CoreBundle/Controller/SecurityController.php | |||
@@ -0,0 +1,27 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Controller; | ||
4 | |||
5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
6 | use Symfony\Component\HttpFoundation\Request; | ||
7 | use Symfony\Component\Security\Core\SecurityContext; | ||
8 | |||
9 | class SecurityController extends Controller | ||
10 | { | ||
11 | public function loginAction(Request $request) | ||
12 | { | ||
13 | $session = $request->getSession(); | ||
14 | // get the login error if there is one | ||
15 | if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) { | ||
16 | $error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR); | ||
17 | } else { | ||
18 | $error = $session->get(SecurityContext::AUTHENTICATION_ERROR); | ||
19 | $session->remove(SecurityContext::AUTHENTICATION_ERROR); | ||
20 | } | ||
21 | return $this->render('WallabagCoreBundle:Security:login.html.twig', array( | ||
22 | // last username entered by the user | ||
23 | 'last_username' => $session->get(SecurityContext::LAST_USERNAME), | ||
24 | 'error' => $error, | ||
25 | )); | ||
26 | } | ||
27 | } \ No newline at end of file | ||
diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php index a6c0db37..8e018e88 100644 --- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php | |||
@@ -82,17 +82,18 @@ class WallabagRestController extends Controller | |||
82 | */ | 82 | */ |
83 | public function postEntriesAction(Request $request) | 83 | public function postEntriesAction(Request $request) |
84 | { | 84 | { |
85 | //TODO la récup ne marche | 85 | //TODO la récup ne marche pas |
86 | //TODO gérer si on passe le titre | 86 | //TODO gérer si on passe le titre |
87 | //TODO gérer si on passe les tags | 87 | //TODO gérer si on passe les tags |
88 | //TODO ne pas avoir du code comme ça qui doit se trouver dans le Repository | 88 | //TODO ne pas avoir du code comme ça qui doit se trouver dans le Repository |
89 | $url = $request->request->get('url'); | ||
90 | |||
91 | $content = Extractor::extract($url); | ||
89 | $entry = new Entries(); | 92 | $entry = new Entries(); |
90 | $entry->setUserId(1); | 93 | $entry->setUserId(1); |
91 | $content = Extractor::extract($request->request->get('url')); | 94 | $entry->setUrl($url); |
92 | |||
93 | $entry->setTitle($content->getTitle()); | 95 | $entry->setTitle($content->getTitle()); |
94 | $entry->setContent($content->getBody()); | 96 | $entry->setContent($content->getBody()); |
95 | |||
96 | $em = $this->getDoctrine()->getManager(); | 97 | $em = $this->getDoctrine()->getManager(); |
97 | $em->persist($entry); | 98 | $em->persist($entry); |
98 | $em->flush(); | 99 | $em->flush(); |