aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/DeveloperController.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@smile.fr>2016-02-16 13:49:25 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2016-02-29 21:28:25 +0100
commitabc329453be6381bcf4d1b0dfd9f698312ed3b16 (patch)
treec4e93bfd9d22223f64b810d7d04f099eb833ed5a /src/Wallabag/CoreBundle/Controller/DeveloperController.php
parent6a2c524a2cee02a0e053574155f173147cd3c870 (diff)
downloadwallabag-abc329453be6381bcf4d1b0dfd9f698312ed3b16.tar.gz
wallabag-abc329453be6381bcf4d1b0dfd9f698312ed3b16.tar.zst
wallabag-abc329453be6381bcf4d1b0dfd9f698312ed3b16.zip
Enhance documentation and create a form to create a new client
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/DeveloperController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/DeveloperController.php38
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;
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Component\HttpFoundation\Request; 6use Symfony\Component\HttpFoundation\Request;
7use Symfony\Bundle\FrameworkBundle\Controller\Controller; 7use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8use Wallabag\ApiBundle\Entity\Client;
9use Wallabag\CoreBundle\Form\Type\ClientType;
8 10
9class DeveloperController extends Controller 11class 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 }