]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/CoreBundle/Controller/DeveloperController.php
Cleanup form
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Controller / DeveloperController.php
CommitLineData
24152cdb
NL
1<?php
2
3namespace Wallabag\CoreBundle\Controller;
4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Component\HttpFoundation\Request;
7use Symfony\Bundle\FrameworkBundle\Controller\Controller;
abc32945
NL
8use Wallabag\ApiBundle\Entity\Client;
9use Wallabag\CoreBundle\Form\Type\ClientType;
24152cdb
NL
10
11class DeveloperController extends Controller
12{
13 /**
24152cdb 14 * @Route("/developer", name="developer")
b6321bed
NL
15 *
16 * @return \Symfony\Component\HttpFoundation\Response
24152cdb 17 */
abc32945 18 public function indexAction()
24152cdb
NL
19 {
20 return $this->render('WallabagCoreBundle:Developer:index.html.twig');
21 }
22
23 /**
24 * @param Request $request
25 *
26 * @Route("/developer/client/create", name="create_client")
b6321bed
NL
27 *
28 * @return \Symfony\Component\HttpFoundation\Response
24152cdb
NL
29 */
30 public function createClientAction(Request $request)
31 {
abc32945
NL
32 $em = $this->getDoctrine()->getManager();
33 $client = new Client();
34 $clientForm = $this->createForm(ClientType::class, $client);
35 $clientForm->handleRequest($request);
36
37 if ($clientForm->isValid()) {
2c2308b7 38 $client->setAllowedGrantTypes(array('token', 'authorization_code', 'password'));
abc32945
NL
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 }
24152cdb
NL
52
53 return $this->render('WallabagCoreBundle:Developer:client.html.twig', array(
abc32945 54 'form' => $clientForm->createView(),
24152cdb
NL
55 ));
56 }
b6321bed
NL
57
58 /**
b6321bed
NL
59 * @Route("/developer/howto/first-app", name="howto-firstapp")
60 *
61 * @return \Symfony\Component\HttpFoundation\Response
62 */
abc32945 63 public function howtoFirstAppAction()
b6321bed
NL
64 {
65 return $this->render('WallabagCoreBundle:Developer:howto_app.html.twig');
66 }
24152cdb 67}