diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/DeveloperController.php | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/DeveloperController.php b/src/Wallabag/CoreBundle/Controller/DeveloperController.php index edbcec4b..3b9da318 100644 --- a/src/Wallabag/CoreBundle/Controller/DeveloperController.php +++ b/src/Wallabag/CoreBundle/Controller/DeveloperController.php | |||
@@ -5,17 +5,17 @@ namespace Wallabag\CoreBundle\Controller; | |||
5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | 5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
6 | use Symfony\Component\HttpFoundation\Request; | 6 | use Symfony\Component\HttpFoundation\Request; |
7 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 7 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
8 | use Wallabag\ApiBundle\Entity\Client; | ||
9 | use Wallabag\CoreBundle\Form\Type\ClientType; | ||
8 | 10 | ||
9 | class DeveloperController extends Controller | 11 | class DeveloperController extends Controller |
10 | { | 12 | { |
11 | /** | 13 | /** |
12 | * @param Request $request | ||
13 | * | ||
14 | * @Route("/developer", name="developer") | 14 | * @Route("/developer", name="developer") |
15 | * | 15 | * |
16 | * @return \Symfony\Component\HttpFoundation\Response | 16 | * @return \Symfony\Component\HttpFoundation\Response |
17 | */ | 17 | */ |
18 | public function indexAction(Request $request) | 18 | public function indexAction() |
19 | { | 19 | { |
20 | return $this->render('WallabagCoreBundle:Developer:index.html.twig'); | 20 | return $this->render('WallabagCoreBundle:Developer:index.html.twig'); |
21 | } | 21 | } |
@@ -29,26 +29,38 @@ class DeveloperController extends Controller | |||
29 | */ | 29 | */ |
30 | public function createClientAction(Request $request) | 30 | public function createClientAction(Request $request) |
31 | { | 31 | { |
32 | $clientManager = $this->container->get('fos_oauth_server.client_manager.default'); | 32 | $em = $this->getDoctrine()->getManager(); |
33 | $client = $clientManager->createClient(); | 33 | $client = new Client(); |
34 | $client->setRedirectUris(array('http://www.example.com')); | 34 | $clientForm = $this->createForm(ClientType::class, $client); |
35 | $client->setAllowedGrantTypes(array('token', 'authorization_code')); | 35 | $clientForm->handleRequest($request); |
36 | $clientManager->updateClient($client); | 36 | |
37 | if ($clientForm->isValid()) { | ||
38 | $client->setAllowedGrantTypes(array('token', 'authorization_code')); | ||
39 | $em->persist($client); | ||
40 | $em->flush(); | ||
41 | |||
42 | $this->get('session')->getFlashBag()->add( | ||
43 | 'notice', | ||
44 | 'New client created.' | ||
45 | ); | ||
46 | |||
47 | return $this->render('WallabagCoreBundle:Developer:client_parameters.html.twig', array( | ||
48 | 'client_id' => $client->getPublicId(), | ||
49 | 'client_secret' => $client->getSecret(), | ||
50 | )); | ||
51 | } | ||
37 | 52 | ||
38 | return $this->render('WallabagCoreBundle:Developer:client.html.twig', array( | 53 | return $this->render('WallabagCoreBundle:Developer:client.html.twig', array( |
39 | 'client_id' => $client->getPublicId(), | 54 | 'form' => $clientForm->createView(), |
40 | 'client_secret' => $client->getSecret(), | ||
41 | )); | 55 | )); |
42 | } | 56 | } |
43 | 57 | ||
44 | /** | 58 | /** |
45 | * @param Request $request | ||
46 | * | ||
47 | * @Route("/developer/howto/first-app", name="howto-firstapp") | 59 | * @Route("/developer/howto/first-app", name="howto-firstapp") |
48 | * | 60 | * |
49 | * @return \Symfony\Component\HttpFoundation\Response | 61 | * @return \Symfony\Component\HttpFoundation\Response |
50 | */ | 62 | */ |
51 | public function howtoFirstAppAction(Request $request) | 63 | public function howtoFirstAppAction() |
52 | { | 64 | { |
53 | return $this->render('WallabagCoreBundle:Developer:howto_app.html.twig'); | 65 | return $this->render('WallabagCoreBundle:Developer:howto_app.html.twig'); |
54 | } | 66 | } |