From 24152cdb5e48edc5128082b285736b06ebda3c82 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 15 Feb 2016 22:12:50 +0100 Subject: [PATCH] Fix #1597: first draft to create new client for the API --- .../Controller/DeveloperController.php | 38 +++++++++++++++++++ .../material/Developer/client.html.twig | 9 +++++ .../themes/material/Developer/index.html.twig | 9 +++++ .../views/themes/material/layout.html.twig | 1 + 4 files changed, 57 insertions(+) create mode 100644 src/Wallabag/CoreBundle/Controller/DeveloperController.php create mode 100644 src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/client.html.twig create mode 100644 src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/index.html.twig diff --git a/src/Wallabag/CoreBundle/Controller/DeveloperController.php b/src/Wallabag/CoreBundle/Controller/DeveloperController.php new file mode 100644 index 00000000..3cb86881 --- /dev/null +++ b/src/Wallabag/CoreBundle/Controller/DeveloperController.php @@ -0,0 +1,38 @@ +render('WallabagCoreBundle:Developer:index.html.twig'); + } + + /** + * @param Request $request + * + * @Route("/developer/client/create", name="create_client") + */ + public function createClientAction(Request $request) + { + $clientManager = $this->container->get('fos_oauth_server.client_manager.default'); + $client = $clientManager->createClient(); + $client->setRedirectUris(array('http://www.example.com')); + $client->setAllowedGrantTypes(array('token', 'authorization_code')); + $clientManager->updateClient($client); + + return $this->render('WallabagCoreBundle:Developer:client.html.twig', array( + 'client_id' => $client->getPublicId(), + )); + } +} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/client.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/client.html.twig new file mode 100644 index 00000000..edebc7ee --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/client.html.twig @@ -0,0 +1,9 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title %}{% trans %}New client{% endtrans %}{% endblock %} + +{% block content %} + + Client ID: {{ client_id }} + +{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/index.html.twig new file mode 100644 index 00000000..9e06005f --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/index.html.twig @@ -0,0 +1,9 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title %}{% trans %}Developer{% endtrans %}{% endblock %} + +{% block content %} + + Create a new client + +{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig index d7bfa7ae..46aab5dc 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig @@ -116,6 +116,7 @@

{% trans %}powered by{% endtrans %} wallabag

{% trans %}About{% endtrans %} + {% trans %}Developer{% endtrans %}
-- 2.41.0