mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-03 14:26:29 +00:00
Fix #1597: first draft to create new client for the API
This commit is contained in:
parent
8808b79230
commit
24152cdb5e
4 changed files with 57 additions and 0 deletions
38
src/Wallabag/CoreBundle/Controller/DeveloperController.php
Normal file
38
src/Wallabag/CoreBundle/Controller/DeveloperController.php
Normal file
|
@ -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(),
|
||||
));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{% extends "WallabagCoreBundle::layout.html.twig" %}
|
||||
|
||||
{% block title %}{% trans %}New client{% endtrans %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
Client ID: {{ client_id }}
|
||||
|
||||
{% endblock %}
|
|
@ -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 %}
|
|
@ -116,6 +116,7 @@
|
|||
<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>
|
||||
|
|
Loading…
Reference in a new issue