Removed templating code

This commit is contained in:
Alex Bilbie 2016-04-10 11:52:18 +01:00
parent d4fb00628e
commit c75d0e0f0e
9 changed files with 0 additions and 377 deletions

View File

@ -11,45 +11,10 @@
namespace League\OAuth2\Server\Grant;
use League\OAuth2\Server\TemplateRenderer\PlatesRenderer;
use League\OAuth2\Server\TemplateRenderer\RendererInterface;
use League\Plates\Engine;
abstract class AbstractAuthorizeGrant extends AbstractGrant
{
/**
* @var \League\OAuth2\Server\TemplateRenderer\RendererInterface
*/
protected $templateRenderer;
/**
* Set the template renderer
*
* @param RendererInterface $templateRenderer
*/
public function setTemplateRenderer(RendererInterface $templateRenderer)
{
$this->templateRenderer = $templateRenderer;
}
/**
* Retrieve template renderer.
*
* @return \League\OAuth2\Server\TemplateRenderer\RendererInterface
*/
protected function getTemplateRenderer()
{
if (!$this->templateRenderer instanceof RendererInterface) {
$this->templateRenderer = new PlatesRenderer(
new Engine(__DIR__ . '/../TemplateRenderer/DefaultTemplates'),
'login_user',
'authorize_client'
);
}
return $this->templateRenderer;
}
/**
* @param string $uri
* @param array $params

View File

@ -1,70 +0,0 @@
<?php
/**
* Base template renderer.
*
* @author Julián Gutiérrez <juliangut@gmail.com>
* @copyright Copyright (c) Alex Bilbie
* @license http://mit-license.org/
*
* @link https://github.com/thephpleague/oauth2-server
*/
namespace League\OAuth2\Server\TemplateRenderer;
abstract class AbstractRenderer implements RendererInterface
{
/**
* @var string
*/
protected $loginTemplate;
/**
* @var string
*/
protected $authorizeTemplate;
/**
* PlatesRenderer constructor.
*
* @param string $loginTemplate
* @param string $authorizeTemplate
*/
public function __construct($loginTemplate, $authorizeTemplate)
{
$this->loginTemplate = $loginTemplate;
$this->authorizeTemplate = $authorizeTemplate;
}
/**
* Render login template.
*
* @param array $data
*
* @return string
*/
public function renderLogin(array $data = [])
{
return $this->render($this->loginTemplate, $data);
}
/**
* Render authorize template.
*
* @param array $data
*
* @return string
*/
public function renderAuthorize(array $data = [])
{
return $this->render($this->authorizeTemplate, $data);
}
/**
* Render template.
*
* @param string $template
* @param array $data
*
* @return string
*/
abstract protected function render($template, array $data = []);
}

View File

@ -1,35 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Authorize <?=$this->e($client->getName())?></title>
</head>
<body>
<h1>
Authorize <?=$this->e($client->getName())?>
</h1>
<p>
Do you want to authorize <?=$this->e($client->getName())?> to access the following data?
</p>
<ul>
<?php foreach ($scopes as $scope): ?>
<li><?=$scope->getIdentifier()?></li>
<?php endforeach; ?>
</ul>
<form method="POST">
<input type="hidden" value="approve" name="action">
<button type="submit">Approve</button>
</form>
<form method="POST">
<input type="hidden" value="deny" name="action">
<button type="submit">Deny</button>
</form>
</body>
</html>

View File

@ -1,35 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Login</title>
</head>
<body>
<h1>Login</h1>
<?php if ($error !== null): ?>
<div style="border:solid 1px red; padding: 1rem; margin-bottom:1rem">
<?=$this->e($error)?>
</div>
<?php endif; ?>
<form method="POST">
<label for="username">Username</label>
<input type="text" id="username" name="username">
<br>
<label for="password">Password</label>
<input type="password" id="password" name="password">
<br>
<input type="submit" value="Login">
</form>
</body>
</html>

View File

@ -1,41 +0,0 @@
<?php
/**
* Mustache template renderer bridge.
*
* @author Julián Gutiérrez <juliangut@gmail.com>
* @copyright Copyright (c) Alex Bilbie
* @license http://mit-license.org/
*
* @link https://github.com/thephpleague/oauth2-server
*/
namespace League\OAuth2\Server\TemplateRenderer;
class MustacheRenderer extends AbstractRenderer
{
/**
* @var \Mustache_Engine
*/
private $engine;
/**
* PlatesRenderer constructor.
*
* @param \Mustache_Engine $engine
* @param string $loginTemplate
* @param string $authorizeTemplate
*/
public function __construct(\Mustache_Engine $engine, $loginTemplate, $authorizeTemplate)
{
parent::__construct($loginTemplate, $authorizeTemplate);
$this->engine = $engine;
}
/**
* {@inheritdoc}
*/
public function render($template, array $data = [])
{
return $this->engine->render($template, $data);
}
}

View File

@ -1,47 +0,0 @@
<?php
/**
* Plates template renderer bridge.
*
* @author Julián Gutiérrez <juliangut@gmail.com>
* @copyright Copyright (c) Alex Bilbie
* @license http://mit-license.org/
*
* @link https://github.com/thephpleague/oauth2-server
*/
namespace League\OAuth2\Server\TemplateRenderer;
use League\Plates\Engine;
class PlatesRenderer extends AbstractRenderer
{
/**
* @var \League\Plates\Engine
*/
private $engine;
/**
* PlatesRenderer constructor.
*
* @param \League\Plates\Engine $engine
* @param string $loginTemplate
* @param string $authorizeTemplate
*/
public function __construct(Engine $engine, $loginTemplate, $authorizeTemplate)
{
parent::__construct($loginTemplate, $authorizeTemplate);
$this->engine = $engine;
}
/**
* {@inheritdoc}
*/
protected function render($template, array $data = [])
{
if ($this->engine->getFileExtension()) {
$template = preg_replace(sprintf('/\.%s$/', $this->engine->getFileExtension()), '', $template);
}
return $this->engine->render($template, $data);
}
}

View File

@ -1,24 +0,0 @@
<?php
namespace League\OAuth2\Server\TemplateRenderer;
interface RendererInterface
{
/**
* Render login template.
*
* @param array $data
*
* @return string
*/
public function renderLogin(array $data = []);
/**
* Render authorize template.
*
* @param array $data
*
* @return string
*/
public function renderAuthorize(array $data = []);
}

View File

@ -1,49 +0,0 @@
<?php
/**
* Smarty template renderer bridge.
*
* @author Julián Gutiérrez <juliangut@gmail.com>
* @copyright Copyright (c) Alex Bilbie
* @license http://mit-license.org/
*
* @link https://github.com/thephpleague/oauth2-server
*/
namespace League\OAuth2\Server\TemplateRenderer;
class SmartyRenderer extends AbstractRenderer
{
/**
* Smarty class.
*
* @var \Smarty
*/
private $smarty;
/**
* PlatesRenderer constructor.
*
* @param \Smarty $smarty
* @param string $loginTemplate
* @param string $authorizeTemplate
*/
public function __construct(\Smarty $smarty, $loginTemplate, $authorizeTemplate)
{
parent::__construct($loginTemplate, $authorizeTemplate);
$this->smarty = $smarty;
}
/**
* {@inheritdoc}
*/
protected function render($template, array $data = [])
{
$this->smarty->assign($data);
$output = $this->smarty->fetch($template);
$this->smarty->clear_assign(array_keys($data));
return $output;
}
}

View File

@ -1,41 +0,0 @@
<?php
/**
* Twig template renderer bridge.
*
* @author Julián Gutiérrez <juliangut@gmail.com>
* @copyright Copyright (c) Alex Bilbie
* @license http://mit-license.org/
*
* @link https://github.com/thephpleague/oauth2-server
*/
namespace League\OAuth2\Server\TemplateRenderer;
class TwigRenderer extends AbstractRenderer
{
/**
* @var \Twig_Environment
*/
private $environment;
/**
* PlatesRenderer constructor.
*
* @param \Twig_Environment $environment
* @param string $loginTemplate
* @param string $authorizeTemplate
*/
public function __construct(\Twig_Environment $environment, $loginTemplate, $authorizeTemplate)
{
parent::__construct($loginTemplate, $authorizeTemplate);
$this->environment = $environment;
}
/**
* {@inheritdoc}
*/
protected function render($template, array $data = [])
{
return $this->environment->loadTemplate($template)->render($data);
}
}