3 namespace Wallabag\CoreBundle\Controller
;
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
;
11 class DeveloperController
extends Controller
14 * List all clients and link to create a new one.
16 * @Route("/developer", name="developer")
18 * @return \Symfony\Component\HttpFoundation\Response
20 public function indexAction()
22 $clients = $this->getDoctrine()->getRepository('WallabagApiBundle:Client')->findAll();
24 return $this->render('WallabagCoreBundle:Developer:index.html.twig', [
25 'clients' => $clients,
30 * Create a client (an app).
32 * @param Request $request
34 * @Route("/developer/client/create", name="developer_create_client")
36 * @return \Symfony\Component\HttpFoundation\Response
38 public function createClientAction(Request
$request)
40 $em = $this->getDoctrine()->getManager();
41 $client = new Client();
42 $clientForm = $this->createForm(ClientType
::class, $client);
43 $clientForm->handleRequest($request);
45 if ($clientForm->isValid()) {
46 $client->setAllowedGrantTypes(['token', 'authorization_code', 'password', 'refresh_token']);
47 $em->persist($client);
50 $this->get('session')->getFlashBag()->add(
52 'flashes.developer.notice.client_created'
55 return $this->render('WallabagCoreBundle:Developer:client_parameters.html.twig', [
56 'client_id' => $client->getPublicId(),
57 'client_secret' => $client->getSecret(),
61 return $this->render('WallabagCoreBundle:Developer:client.html.twig', [
62 'form' => $clientForm->createView(),
69 * @param Client $client
71 * @Route("/developer/client/delete/{id}", requirements={"id" = "\d+"}, name="developer_delete_client")
73 * @return \Symfony\Component\HttpFoundation\RedirectResponse
75 public function deleteClientAction(Client
$client)
77 $em = $this->getDoctrine()->getManager();
81 $this->get('session')->getFlashBag()->add(
83 'flashes.developer.notice.client_deleted'
86 return $this->redirect($this->generateUrl('developer'));
90 * Display developer how to use an existing app.
92 * @Route("/developer/howto/first-app", name="developer_howto_firstapp")
94 * @return \Symfony\Component\HttpFoundation\Response
96 public function howtoFirstAppAction()
98 return $this->render('WallabagCoreBundle:Developer:howto_app.html.twig');