]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/CoreBundle/Controller/DeveloperController.php
Add password for auth
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Controller / DeveloperController.php
1 <?php
2
3 namespace Wallabag\CoreBundle\Controller;
4
5 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6 use Symfony\Component\HttpFoundation\Request;
7 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8 use Wallabag\ApiBundle\Entity\Client;
9 use Wallabag\CoreBundle\Form\Type\ClientType;
10
11 class DeveloperController extends Controller
12 {
13 /**
14 * @Route("/developer", name="developer")
15 *
16 * @return \Symfony\Component\HttpFoundation\Response
17 */
18 public function indexAction()
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")
27 *
28 * @return \Symfony\Component\HttpFoundation\Response
29 */
30 public function createClientAction(Request $request)
31 {
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()) {
38 $client->setAllowedGrantTypes(array('token', 'authorization_code','password'));
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 }
52
53 return $this->render('WallabagCoreBundle:Developer:client.html.twig', array(
54 'form' => $clientForm->createView(),
55 ));
56 }
57
58 /**
59 * @Route("/developer/howto/first-app", name="howto-firstapp")
60 *
61 * @return \Symfony\Component\HttpFoundation\Response
62 */
63 public function howtoFirstAppAction()
64 {
65 return $this->render('WallabagCoreBundle:Developer:howto_app.html.twig');
66 }
67 }