diff --git a/src/Grant/AbstractAuthorizeGrant.php b/src/Grant/AbstractAuthorizeGrant.php index aa578335..4d086711 100644 --- a/src/Grant/AbstractAuthorizeGrant.php +++ b/src/Grant/AbstractAuthorizeGrant.php @@ -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 diff --git a/src/TemplateRenderer/AbstractRenderer.php b/src/TemplateRenderer/AbstractRenderer.php deleted file mode 100644 index 0dc3e1ae..00000000 --- a/src/TemplateRenderer/AbstractRenderer.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @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 = []); -} diff --git a/src/TemplateRenderer/DefaultTemplates/authorize_client.php b/src/TemplateRenderer/DefaultTemplates/authorize_client.php deleted file mode 100644 index 81587174..00000000 --- a/src/TemplateRenderer/DefaultTemplates/authorize_client.php +++ /dev/null @@ -1,35 +0,0 @@ - - - - - Authorize <?=$this->e($client->getName())?> - - - - -

- Authorize e($client->getName())?> -

- -

- Do you want to authorize e($client->getName())?> to access the following data? -

- - - -
- - -
- -
- - -
- - - \ No newline at end of file diff --git a/src/TemplateRenderer/DefaultTemplates/login_user.php b/src/TemplateRenderer/DefaultTemplates/login_user.php deleted file mode 100644 index 75b6b529..00000000 --- a/src/TemplateRenderer/DefaultTemplates/login_user.php +++ /dev/null @@ -1,35 +0,0 @@ - - - - - Login - - - - -

Login

- - -
- e($error)?> -
- - -
- - - - -
- - - - -
- - - -
- - - \ No newline at end of file diff --git a/src/TemplateRenderer/MustacheRenderer.php b/src/TemplateRenderer/MustacheRenderer.php deleted file mode 100644 index fbc0abe9..00000000 --- a/src/TemplateRenderer/MustacheRenderer.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @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); - } -} diff --git a/src/TemplateRenderer/PlatesRenderer.php b/src/TemplateRenderer/PlatesRenderer.php deleted file mode 100644 index 6cd4a77b..00000000 --- a/src/TemplateRenderer/PlatesRenderer.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @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); - } -} diff --git a/src/TemplateRenderer/RendererInterface.php b/src/TemplateRenderer/RendererInterface.php deleted file mode 100644 index 74d9b48f..00000000 --- a/src/TemplateRenderer/RendererInterface.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @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; - } -} diff --git a/src/TemplateRenderer/TwigRenderer.php b/src/TemplateRenderer/TwigRenderer.php deleted file mode 100644 index e4e0c13d..00000000 --- a/src/TemplateRenderer/TwigRenderer.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @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); - } -}