]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Fix #1597: first draft to create new client for the API
authorNicolas Lœuillet <nicolas@loeuillet.org>
Mon, 15 Feb 2016 21:12:50 +0000 (22:12 +0100)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Mon, 29 Feb 2016 20:28:25 +0000 (21:28 +0100)
src/Wallabag/CoreBundle/Controller/DeveloperController.php [new file with mode: 0644]
src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/client.html.twig [new file with mode: 0644]
src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/index.html.twig [new file with mode: 0644]
src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig

diff --git a/src/Wallabag/CoreBundle/Controller/DeveloperController.php b/src/Wallabag/CoreBundle/Controller/DeveloperController.php
new file mode 100644 (file)
index 0000000..3cb8688
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+
+namespace Wallabag\CoreBundle\Controller;
+
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+
+class DeveloperController extends Controller
+{
+    /**
+     * @param Request $request
+     *
+     * @Route("/developer", name="developer")
+     */
+    public function indexAction(Request $request)
+    {
+        return $this->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 (file)
index 0000000..edebc7e
--- /dev/null
@@ -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 (file)
index 0000000..9e06005
--- /dev/null
@@ -0,0 +1,9 @@
+{% extends "WallabagCoreBundle::layout.html.twig" %}
+
+{% block title %}{% trans %}Developer{% endtrans %}{% endblock %}
+
+{% block content %}
+
+    <a href="{{ path('create_client') }}">Create a new client</a>
+
+{% endblock %}
index d7bfa7aede2ab106b96f4ae37c534fdc9316d85a..46aab5dcacf35dd8414494f6b03b11b83de3fd7e 100644 (file)
             <div class="container">
                 <p>{% trans %}powered by{% endtrans %} <a target="_blank" href="https://wallabag.org" class="grey-text text-lighten-4">wallabag</a></p>
                 <a class="grey-text text-lighten-4 right" href="{{ path('about') }}">{% trans %}About{% endtrans %}</a>
+                <a class="grey-text text-lighten-4 right" href="{{ path('developer') }}">{% trans %}Developer{% endtrans %}
             </div>
         </div>
     </footer>