├── src ├── Exception │ ├── ExceptionInterface.php │ ├── MissingHelperException.php │ └── InvalidExtensionException.php ├── ConfigProvider.php ├── Extension │ ├── EscaperExtensionFactory.php │ ├── EscaperExtension.php │ ├── UrlExtensionFactory.php │ └── UrlExtension.php ├── PlatesRendererFactory.php ├── PlatesRenderer.php └── PlatesEngineFactory.php ├── README.md ├── LICENSE.md ├── composer.json └── CHANGELOG.md /src/Exception/ExceptionInterface.php: -------------------------------------------------------------------------------- 1 | $this->getDependencies(), 20 | 'templates' => $this->getTemplates(), 21 | ]; 22 | } 23 | 24 | public function getDependencies() : array 25 | { 26 | return [ 27 | 'aliases' => [ 28 | TemplateRendererInterface::class => PlatesRenderer::class, 29 | ], 30 | 'factories' => [ 31 | PlatesRenderer::class => PlatesRendererFactory::class, 32 | ], 33 | ]; 34 | } 35 | 36 | public function getTemplates() : array 37 | { 38 | return [ 39 | 'extension' => 'phtml', 40 | 'paths' => [], 41 | ]; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Extension/EscaperExtensionFactory.php: -------------------------------------------------------------------------------- 1 | 22 | * 'plates' => [ 23 | * 'encoding' => 'global encoding value, if not set then will fallback to UTF-8' 24 | * ] 25 | * 26 | */ 27 | class EscaperExtensionFactory 28 | { 29 | /** 30 | * @throws InvalidArgumentException 31 | */ 32 | public function __invoke(ContainerInterface $container) : EscaperExtension 33 | { 34 | $config = $container->has('config') ? $container->get('config') : []; 35 | $config = $config['plates'] ?? []; 36 | 37 | // Create new EscaperExtension instance 38 | return new EscaperExtension($config['encoding'] ?? null); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Plates Integration for Expressive 2 | 3 | > ## Repository abandoned 2019-12-31 4 | > 5 | > This repository has moved to [mezzio/mezzio-platesrenderer](https://github.com/mezzio/mezzio-platesrenderer). 6 | 7 | [![Build Status](https://secure.travis-ci.org/zendframework/zend-expressive-platesrenderer.svg?branch=master)](https://secure.travis-ci.org/zendframework/zend-expressive-platesrenderer) 8 | [![Coverage Status](https://coveralls.io/repos/github/zendframework/zend-expressive-platesrenderer/badge.svg?branch=master)](https://coveralls.io/github/zendframework/zend-expressive-platesrenderer?branch=master) 9 | 10 | Provides integration with [Plates](http://platesphp.com/) for 11 | [Expressive](https://github.com/zendframework/zend-expressive). 12 | 13 | ## Installation 14 | 15 | Install this library using composer: 16 | 17 | ```bash 18 | $ composer require zendframework/zend-expressive-platesrenderer 19 | ``` 20 | 21 | We recommend using a dependency injection container, and typehint against 22 | [container-interop](https://github.com/container-interop/container-interop). We 23 | can recommend the following implementations: 24 | 25 | - [zend-servicemanager](https://github.com/zendframework/zend-servicemanager): 26 | `composer require zendframework/zend-servicemanager` 27 | - [pimple-interop](https://github.com/moufmouf/pimple-interop): 28 | `composer require mouf/pimple-interop` 29 | - [Aura.Di](https://github.com/auraphp/Aura.Di) 30 | 31 | ## Documentation 32 | 33 | See the Expressive [Plates documentation](https://docs.zendframework.com/zend-expressive/features/template/plates/). 34 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015-2018, Zend Technologies USA, Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | - Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | - Redistributions in binary form must reproduce the above copyright notice, this 11 | list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | - Neither the name of Zend Technologies USA, Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from this 16 | software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /src/Extension/EscaperExtension.php: -------------------------------------------------------------------------------- 1 | escaper = new Escaper($encoding); 29 | } 30 | 31 | /** 32 | * Register functions with the Plates engine. 33 | * 34 | * Registers: 35 | * 36 | * - escapeHtml($string) : string 37 | * - escapeHtmlAttr($string) : string 38 | * - escapeJs($string) : string 39 | * - escapeCss($string) : string 40 | * - escapeUrl($string) : string 41 | * 42 | * @param Engine $engine 43 | * @return void 44 | */ 45 | public function register(Engine $engine) : void 46 | { 47 | $engine->registerFunction('escapeHtml', [$this->escaper, 'escapeHtml']); 48 | $engine->registerFunction('escapeHtmlAttr', [$this->escaper, 'escapeHtmlAttr']); 49 | $engine->registerFunction('escapeJs', [$this->escaper, 'escapeJs']); 50 | $engine->registerFunction('escapeCss', [$this->escaper, 'escapeCss']); 51 | $engine->registerFunction('escapeUrl', [$this->escaper, 'escapeUrl']); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Extension/UrlExtensionFactory.php: -------------------------------------------------------------------------------- 1 | has(UrlHelper::class)) { 31 | throw new MissingHelperException(sprintf( 32 | '%s requires that the %s service be present; not found', 33 | UrlExtension::class, 34 | UrlHelper::class 35 | )); 36 | } 37 | 38 | if (! $container->has(ServerUrlHelper::class)) { 39 | throw new MissingHelperException(sprintf( 40 | '%s requires that the %s service be present; not found', 41 | UrlExtension::class, 42 | ServerUrlHelper::class 43 | )); 44 | } 45 | 46 | return new UrlExtension( 47 | $container->get(UrlHelper::class), 48 | $container->get(ServerUrlHelper::class) 49 | ); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zendframework/zend-expressive-platesrenderer", 3 | "description": "Plates integration for Expressive", 4 | "license": "BSD-3-Clause", 5 | "keywords": [ 6 | "expressive", 7 | "http", 8 | "league", 9 | "plates", 10 | "psr", 11 | "psr-7", 12 | "zf", 13 | "zendframework", 14 | "zend-expressive" 15 | ], 16 | "support": { 17 | "issues": "https://github.com/zendframework/zend-expressive-platesrenderer/issues", 18 | "source": "https://github.com/zendframework/zend-expressive-platesrenderer", 19 | "rss": "https://github.com/zendframework/zend-expressive-platesrenderer/releases.atom", 20 | "slack": "https://zendframework-slack.herokuapp.com", 21 | "forum": "https://discourse.zendframework.com/c/questions/expressive" 22 | }, 23 | "require": { 24 | "php": "^7.1", 25 | "league/plates": "^3.3", 26 | "psr/container": "^1.0", 27 | "zendframework/zend-expressive-helpers": "^5.2", 28 | "zendframework/zend-expressive-router": "^3.0", 29 | "zendframework/zend-expressive-template": "^2.0", 30 | "zendframework/zend-escaper": "^2.5" 31 | }, 32 | "require-dev": { 33 | "malukenho/docheader": "^0.1.5", 34 | "phpunit/phpunit": "^7.0.2", 35 | "zendframework/zend-coding-standard": "~1.0.0" 36 | }, 37 | "conflict": { 38 | "container-interop/container-interop": "<1.2.0" 39 | }, 40 | "autoload": { 41 | "psr-4": { 42 | "Zend\\Expressive\\Plates\\": "src/" 43 | } 44 | }, 45 | "autoload-dev": { 46 | "psr-4": { 47 | "ZendTest\\Expressive\\Plates\\": "test/" 48 | } 49 | }, 50 | "config": { 51 | "sort-packages": true 52 | }, 53 | "extra": { 54 | "branch-alias": { 55 | "dev-master": "2.1.x-dev", 56 | "dev-develop": "2.2.x-dev" 57 | }, 58 | "zf": { 59 | "config-provider": "Zend\\Expressive\\Plates\\ConfigProvider" 60 | } 61 | }, 62 | "scripts": { 63 | "check": [ 64 | "@license-check", 65 | "@cs-check", 66 | "@test" 67 | ], 68 | "cs-check": "phpcs", 69 | "cs-fix": "phpcbf", 70 | "test": "phpunit --colors=always", 71 | "test-coverage": "phpunit --colors=always --coverage-clover clover.xml", 72 | "license-check": "docheader check src/" 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/PlatesRendererFactory.php: -------------------------------------------------------------------------------- 1 | 25 | * 'templates' => [ 26 | * 'extension' => 'file extension used by templates; defaults to html', 27 | * 'paths' => [ 28 | * // namespace / path pairs 29 | * // 30 | * // Numeric namespaces imply the default/main namespace. Paths may be 31 | * // strings or arrays of string paths to associate with the namespace. 32 | * ], 33 | * ] 34 | * 35 | * 36 | * If the service League\Plates\Engine exists, that value will be used 37 | * for the PlatesEngine; otherwise, this factory invokes the PlatesEngineFactory 38 | * to create an instance. 39 | */ 40 | class PlatesRendererFactory 41 | { 42 | public function __invoke(ContainerInterface $container) : PlatesRenderer 43 | { 44 | $config = $container->has('config') ? $container->get('config') : []; 45 | $config = $config['templates'] ?? []; 46 | 47 | // Create the engine instance: 48 | $engine = $this->createEngine($container); 49 | 50 | // Set file extension 51 | if (isset($config['extension'])) { 52 | $engine->setFileExtension($config['extension']); 53 | } 54 | 55 | // Inject engine 56 | $plates = new PlatesRenderer($engine); 57 | 58 | // Add template paths 59 | $allPaths = isset($config['paths']) && is_array($config['paths']) ? $config['paths'] : []; 60 | foreach ($allPaths as $namespace => $paths) { 61 | $namespace = is_numeric($namespace) ? null : $namespace; 62 | foreach ((array) $paths as $path) { 63 | $plates->addPath($path, $namespace); 64 | } 65 | } 66 | 67 | return $plates; 68 | } 69 | 70 | /** 71 | * Create and return a Plates Engine instance. 72 | * 73 | * If the container has the League\Plates\Engine service, returns it. 74 | * 75 | * Otherwise, invokes the PlatesEngineFactory with the $container to create 76 | * and return the instance. 77 | */ 78 | private function createEngine(ContainerInterface $container) : PlatesEngine 79 | { 80 | if ($container->has(PlatesEngine::class)) { 81 | return $container->get(PlatesEngine::class); 82 | } 83 | 84 | $engineFactory = new PlatesEngineFactory(); 85 | return $engineFactory($container); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/Extension/UrlExtension.php: -------------------------------------------------------------------------------- 1 | urlHelper = $urlHelper; 37 | $this->serverUrlHelper = $serverUrlHelper; 38 | } 39 | 40 | /** 41 | * Register functions with the Plates engine. 42 | * 43 | * Registers: 44 | * 45 | * - url($route = null, array $params = []) : string 46 | * - serverurl($path = null) : string 47 | */ 48 | public function register(Engine $engine) : void 49 | { 50 | $engine->registerFunction('url', $this->urlHelper); 51 | $engine->registerFunction('serverurl', $this->serverUrlHelper); 52 | $engine->registerFunction('route', [$this->urlHelper, 'getRouteResult']); 53 | } 54 | 55 | /** 56 | * Get the RouteResult instance of UrlHelper, if any. 57 | * 58 | * @deprecated since 2.2.0; to be removed in 3.0.0. This method was originally 59 | * used internally to back the route() Plates function; we now register 60 | * the UrlHelper::getRouteResult callback directly. 61 | */ 62 | public function getRouteResult() : ?RouteResult 63 | { 64 | return $this->urlHelper->getRouteResult(); 65 | } 66 | 67 | /** 68 | * Generate a URL from either the currently matched route or the specfied route. 69 | * 70 | * @param array $options Can have the following keys: 71 | * - router (array): contains options to be passed to the router 72 | * - reuse_result_params (bool): indicates if the current RouteResult 73 | * parameters will be used, defaults to true 74 | * @return string 75 | * @deprecated since 2.2.0; to be removed in 3.0.0. This method was originally 76 | * used internally to back the url() Plates function; we now register 77 | * UrlHelper instance directly, as it is callable. 78 | */ 79 | public function generateUrl( 80 | string $routeName = null, 81 | array $routeParams = [], 82 | array $queryParams = [], 83 | ?string $fragmentIdentifier = null, 84 | array $options = [] 85 | ) { 86 | return $this->urlHelper->generate($routeName, $routeParams, $queryParams, $fragmentIdentifier, $options); 87 | } 88 | 89 | /** 90 | * Generate a fully qualified URI, relative to $path. 91 | * 92 | * @deprecated since 2.2.0; to be removed in 3.0.0. This method was originally 93 | * used internally to back the serverurl() Plates function; we now register 94 | * the ServerUrl instance directly, as it is callable. 95 | */ 96 | public function generateServerUrl(string $path = null) : string 97 | { 98 | return $this->serverUrlHelper->generate($path); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/PlatesRenderer.php: -------------------------------------------------------------------------------- 1 | createTemplate(); 44 | } 45 | $this->template = $template; 46 | } 47 | 48 | /** 49 | * {@inheritDoc} 50 | */ 51 | public function render(string $name, $params = []) : string 52 | { 53 | $params = $this->normalizeParams($params); 54 | return $this->template->render($name, $params); 55 | } 56 | 57 | /** 58 | * Add a path for template 59 | * 60 | * Multiple calls to this method without a namespace will trigger an 61 | * E_USER_WARNING and act as a no-op. Plates does not handle non-namespaced 62 | * folders, only the default directory; overwriting the default directory 63 | * is likely unintended. 64 | */ 65 | public function addPath(string $path, string $namespace = null) : void 66 | { 67 | if (! $namespace && ! $this->template->getDirectory()) { 68 | $this->template->setDirectory($path); 69 | return; 70 | } 71 | 72 | if (! $namespace) { 73 | trigger_error('Cannot add duplicate un-namespaced path in Plates template adapter', E_USER_WARNING); 74 | return; 75 | } 76 | 77 | $this->template->addFolder($namespace, $path, true); 78 | } 79 | 80 | /** 81 | * {@inheritDoc} 82 | */ 83 | public function getPaths() : array 84 | { 85 | $paths = $this->template->getDirectory() 86 | ? [ $this->getDefaultPath() ] 87 | : []; 88 | 89 | foreach ($this->getPlatesFolders() as $folder) { 90 | $paths[] = new TemplatePath($folder->getPath(), $folder->getName()); 91 | } 92 | return $paths; 93 | } 94 | 95 | /** 96 | * Proxies to the Plate Engine's `addData()` method. 97 | * 98 | * {@inheritDoc} 99 | */ 100 | public function addDefaultParam(string $templateName, string $param, $value) : void 101 | { 102 | if (! is_string($templateName) || empty($templateName)) { 103 | throw new Exception\InvalidArgumentException(sprintf( 104 | '$templateName must be a non-empty string; received %s', 105 | is_object($templateName) ? get_class($templateName) : gettype($templateName) 106 | )); 107 | } 108 | 109 | if (! is_string($param) || empty($param)) { 110 | throw new Exception\InvalidArgumentException(sprintf( 111 | '$param must be a non-empty string; received %s', 112 | is_object($param) ? get_class($param) : gettype($param) 113 | )); 114 | } 115 | 116 | $params = [$param => $value]; 117 | 118 | if ($templateName === self::TEMPLATE_ALL) { 119 | $templateName = null; 120 | } 121 | 122 | $this->template->addData($params, $templateName); 123 | } 124 | 125 | 126 | /** 127 | * Create a default Plates engine 128 | */ 129 | private function createTemplate() : Engine 130 | { 131 | return new Engine(); 132 | } 133 | 134 | /** 135 | * Create and return a TemplatePath representing the default Plates directory. 136 | */ 137 | private function getDefaultPath() : TemplatePath 138 | { 139 | return new TemplatePath($this->template->getDirectory()); 140 | } 141 | 142 | /** 143 | * Return the internal array of plates folders. 144 | * 145 | * @return \League\Plates\Template\Folder[] 146 | */ 147 | private function getPlatesFolders() : array 148 | { 149 | $folders = $this->template->getFolders(); 150 | $r = new ReflectionProperty($folders, 'folders'); 151 | $r->setAccessible(true); 152 | return $r->getValue($folders); 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /src/PlatesEngineFactory.php: -------------------------------------------------------------------------------- 1 | 32 | * 'plates' => [ 33 | * 'extensions' => [ 34 | * // extension instances, or 35 | * // service names that return extension instances, or 36 | * // class names of directly instantiable extensions. 37 | * ] 38 | * ] 39 | * 40 | * 41 | * By default, this factory attaches the Extension\UrlExtension 42 | * and Extension\EscaperExtension to the engine. You can override 43 | * the functions that extension exposes by providing an extension 44 | * class in your extensions array, or providing an alternative 45 | * Zend\Expressive\Plates\Extension\UrlExtension service. 46 | */ 47 | class PlatesEngineFactory 48 | { 49 | public function __invoke(ContainerInterface $container) : PlatesEngine 50 | { 51 | $config = $container->has('config') ? $container->get('config') : []; 52 | $config = $config['plates'] ?? []; 53 | 54 | // Create the engine instance: 55 | $engine = new PlatesEngine(); 56 | 57 | $this->injectUrlExtension($container, $engine); 58 | $this->injectEscaperExtension($container, $engine); 59 | 60 | if (isset($config['extensions']) && is_array($config['extensions'])) { 61 | $this->injectExtensions($container, $engine, $config['extensions']); 62 | } 63 | 64 | return $engine; 65 | } 66 | 67 | /** 68 | * Inject the URL/ServerUrl extensions provided by this package. 69 | * 70 | * If a service by the name of the UrlExtension class exists, fetches 71 | * and loads it. 72 | * 73 | * Otherwise, instantiates the UrlExtensionFactory, and invokes it with 74 | * the container, loading the result into the engine. 75 | */ 76 | private function injectUrlExtension(ContainerInterface $container, PlatesEngine $engine) : void 77 | { 78 | if ($container->has(Extension\UrlExtension::class)) { 79 | $engine->loadExtension($container->get(Extension\UrlExtension::class)); 80 | return; 81 | } 82 | 83 | // If the extension was not explicitly registered, load it only if both helpers were registered 84 | if (! $container->has(Helper\UrlHelper::class) || ! $container->has(Helper\ServerUrlHelper::class)) { 85 | return; 86 | } 87 | 88 | $extensionFactory = new Extension\UrlExtensionFactory(); 89 | $engine->loadExtension($extensionFactory($container)); 90 | } 91 | 92 | /** 93 | * Inject the Escaper extension provided by this package. 94 | * 95 | * If a service by the name of the EscaperExtension class exists, fetches 96 | * and loads it. 97 | * 98 | * Otherwise, instantiates the EscaperExtensionFactory, and invokes it with 99 | * the container, loading the result into the engine. 100 | */ 101 | private function injectEscaperExtension(ContainerInterface $container, PlatesEngine $engine) : void 102 | { 103 | if ($container->has(Extension\EscaperExtension::class)) { 104 | $engine->loadExtension($container->get(Extension\EscaperExtension::class)); 105 | return; 106 | } 107 | 108 | $extensionFactory = new Extension\EscaperExtensionFactory(); 109 | $engine->loadExtension($extensionFactory($container)); 110 | } 111 | 112 | /** 113 | * Inject all configured extensions into the engine. 114 | */ 115 | private function injectExtensions(ContainerInterface $container, PlatesEngine $engine, array $extensions) : void 116 | { 117 | foreach ($extensions as $extension) { 118 | $this->injectExtension($container, $engine, $extension); 119 | } 120 | } 121 | 122 | /** 123 | * Inject an extension into the engine. 124 | * 125 | * Valid extension specifications include: 126 | * 127 | * - ExtensionInterface instances 128 | * - String service names that resolve to ExtensionInterface instances 129 | * - String class names that resolve to ExtensionInterface instances 130 | * 131 | * If anything else is provided, an exception is raised. 132 | * 133 | * @param ExtensionInterface|string $extension 134 | * @throws Exception\InvalidExtensionException for non-string, 135 | * non-extension $extension values. 136 | * @throws Exception\InvalidExtensionException for string $extension values 137 | * that do not resolve to an extension instance. 138 | */ 139 | private function injectExtension(ContainerInterface $container, PlatesEngine $engine, $extension) : void 140 | { 141 | if ($extension instanceof ExtensionInterface) { 142 | $engine->loadExtension($extension); 143 | return; 144 | } 145 | 146 | if (! is_string($extension)) { 147 | throw new Exception\InvalidExtensionException(sprintf( 148 | '%s expects extension instances, service names, or class names; received %s', 149 | __CLASS__, 150 | (is_object($extension) ? get_class($extension) : gettype($extension)) 151 | )); 152 | } 153 | 154 | if (! $container->has($extension) && ! class_exists($extension)) { 155 | throw new Exception\InvalidExtensionException(sprintf( 156 | '%s expects extension service names or class names; "%s" does not resolve to either', 157 | __CLASS__, 158 | $extension 159 | )); 160 | } 161 | 162 | $extension = $container->has($extension) 163 | ? $container->get($extension) 164 | : new $extension(); 165 | 166 | if (! $extension instanceof ExtensionInterface) { 167 | throw new Exception\InvalidExtensionException(sprintf( 168 | '%s expects extension services to implement %s ; received %s', 169 | __CLASS__, 170 | ExtensionInterface::class, 171 | (is_object($extension) ? get_class($extension) : gettype($extension)) 172 | )); 173 | } 174 | 175 | $engine->loadExtension($extension); 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file, in reverse chronological order by release. 4 | 5 | ## 2.2.1 - TBD 6 | 7 | ### Added 8 | 9 | - Nothing. 10 | 11 | ### Changed 12 | 13 | - Nothing. 14 | 15 | ### Deprecated 16 | 17 | - Nothing. 18 | 19 | ### Removed 20 | 21 | - Nothing. 22 | 23 | ### Fixed 24 | 25 | - Nothing. 26 | 27 | ## 2.2.0 - 2019-10-08 28 | 29 | ### Added 30 | 31 | - Nothing. 32 | 33 | ### Changed 34 | 35 | - [#37](https://github.com/zendframework/zend-expressive-platesrenderer/pull/37) changes some internal logic in how the UrlHelper and ServerUrlHelper are exposed as Plates functions, reducing the number of nested calls and improving performance. 36 | 37 | ### Deprecated 38 | 39 | - [#37](https://github.com/zendframework/zend-expressive-platesrenderer/pull/37) deprecates the method `Zend\Expressive\Plates\Extension\UrlExtension::generateServerUrl()`. Originally, the extension registered this method with the Plates engine as the function `serverurl()`; we now register the `Zend\Expressive\Helper\ServerUrlHelper` instance directly (as it is callable), making the method obsolete. It will be removed in version 3.0.0. 40 | 41 | - [#37](https://github.com/zendframework/zend-expressive-platesrenderer/pull/37) deprecates the method `Zend\Expressive\Plates\Extension\UrlExtension::generateUrl()`. Originally, the extension registered this method with the Plates engine as the function `url()`; we now register the `Zend\Expressive\Helper\UrlHelper` instance directly (as it is callable), making the method obsolete. It will be removed in version 3.0.0. 42 | 43 | - [#37](https://github.com/zendframework/zend-expressive-platesrenderer/pull/37) deprecates the method `Zend\Expressive\Plates\Extension\UrlExtension::getRouteResult()`. Originally, the extension registered this method with the Plates engine as the function `route()`; we now register the `Zend\Expressive\Helper\UrlHelper::getRouteResult()` method directly, making the method obsolete. It will be removed in version 3.0.0. 44 | 45 | ### Removed 46 | 47 | - Nothing. 48 | 49 | ### Fixed 50 | 51 | - Nothing. 52 | 53 | ## 2.1.0 - 2019-03-12 54 | 55 | ### Added 56 | 57 | - [#36](https://github.com/zendframework/zend-expressive-platesrenderer/pull/36) adds the template function `route()`, which will return a 58 | `Zend\Expressive\Router\RouteResult` or `null`, based on the presence or 59 | absence of a `RouteResult` in the `Zend\Expressive\Helper\UrlHelper` instance 60 | composed. This can be used to get the matched route name and/or parameters. 61 | 62 | ### Changed 63 | 64 | - Nothing. 65 | 66 | ### Deprecated 67 | 68 | - Nothing. 69 | 70 | ### Removed 71 | 72 | - Nothing. 73 | 74 | ### Fixed 75 | 76 | - Nothing. 77 | 78 | ## 2.0.0 - 2018-03-15 79 | 80 | ### Added 81 | 82 | - [#27](https://github.com/zendframework/zend-expressive-platesrenderer/pull/27) and 83 | [#32](https://github.com/zendframework/zend-expressive-platesrenderer/pull/32) 84 | add support for the zend-expressive-template v2 series, 85 | zend-expressive-router v3 series, and zend-expressive-helpers v5 series. 86 | 87 | - [#29](https://github.com/zendframework/zend-expressive-platesrenderer/pull/29) 88 | adds a `ConfigProvider` class with default service wiring and configuration 89 | for the component. It also updates `composer.json` to add 90 | `extra.zf.config-provider` configuration to notify zend-component-installer 91 | of the shipped `ConfigProvider` class, allowing the plugin to inject the 92 | `ConfigProvider` in your application configuration during initial 93 | installation. 94 | 95 | ### Changed 96 | 97 | - [#27](https://github.com/zendframework/zend-expressive-platesrenderer/pull/27) 98 | updates all classes to use scalar typehints and return typehints, including 99 | nullable types and void types, whenever possible, in order to improve 100 | reliability and predictability of operation. 101 | 102 | - [#28](https://github.com/zendframework/zend-expressive-platesrenderer/pull/28) 103 | updates the package `ExceptionInterface` to extend from the 104 | `ExceptionInterface` provided in zend-expressive-template. 105 | 106 | ### Deprecated 107 | 108 | - Nothing. 109 | 110 | ### Removed 111 | 112 | - [#27](https://github.com/zendframework/zend-expressive-platesrenderer/pull/27) 113 | drops support for zend-expressive-template v1. 114 | 115 | - [#27](https://github.com/zendframework/zend-expressive-platesrenderer/pull/27) 116 | drops support for PHP versions prior to PHP 7.1. 117 | 118 | ### Fixed 119 | 120 | - Nothing. 121 | 122 | ## 1.4.0 - 2017-11-02 123 | 124 | ### Added 125 | 126 | - [#22](https://github.com/zendframework/zend-expressive-platesrenderer/pull/22) 127 | adds `Zend\Expressive\PlatesRenderer\Extension\EscaperExtension`, as well as a 128 | factory for the extension. This extension provides context-specific escaper 129 | helpers to the Plates engine, based on zend-escaper: `escapeHtml()`, 130 | `escapeHtmlAttr()`, `escapeJs()`, `escapeCss()`, and `escapeUrl()`. These are 131 | registered by default with the Plates engine. If you wish to provide 132 | alternates, provide a `Zend\Expressive\PlatesRenderer\Extension\EscaperExtension` 133 | service that provides the custom extension. 134 | 135 | ### Changed 136 | 137 | - [#19](https://github.com/zendframework/zend-expressive-platesrenderer/pull/19) 138 | changes all factories to typehint against the PSR-11 139 | `Psr\Container\ContainerInterface` instead of 140 | `Interop\Container\ContainerInterface`. This change is backwards compatible 141 | for consumers, as container-interop interfaces extend from PSR-11 at this 142 | time. However, if you were _extending_ any of the factories, you will need to 143 | update your code to use the new typehints. (We expect very few extensions, as 144 | typically delegator factories will be used to modify instances returned by 145 | factories, or custom factories will be written.) 146 | 147 | ### Deprecated 148 | 149 | - Nothing. 150 | 151 | ### Removed 152 | 153 | - Nothing. 154 | 155 | ### Fixed 156 | 157 | - Nothing. 158 | 159 | ## 1.3.2 - 2017-11-01 160 | 161 | ### Added 162 | 163 | - Nothing. 164 | 165 | ### Deprecated 166 | 167 | - Nothing. 168 | 169 | ### Removed 170 | 171 | - Nothing. 172 | 173 | ### Fixed 174 | 175 | - [#25](https://github.com/zendframework/zend-expressive-platesrenderer/pull/25) 176 | modifies the `PlatesEngineFactory` such that it now skips injection of the 177 | `UrlExtension` if zend-expressive-helpers is not installed. This change allows 178 | usage of the package outside the Expressive ecosystem. 179 | 180 | ## 1.3.1 - 2017-03-14 181 | 182 | ### Added 183 | 184 | - Nothing. 185 | 186 | ### Deprecated 187 | 188 | - Nothing. 189 | 190 | ### Removed 191 | 192 | - Nothing. 193 | 194 | ### Fixed 195 | 196 | - [#17](https://github.com/zendframework/zend-expressive-platesrenderer/pull/17) 197 | fixes the default value of the `UrlExtension`'s `$fragmentIdentifier` to be 198 | `null` instead of an empty string. 199 | 200 | ## 1.3.0 - 2017-03-14 201 | 202 | ### Added 203 | 204 | - [#18](https://github.com/zendframework/zend-expressive-platesrenderer/pull/18) 205 | adds support for zend-expressive-helpers 4.0. 206 | 207 | ### Deprecated 208 | 209 | - Nothing. 210 | 211 | ### Removed 212 | 213 | - Nothing. 214 | 215 | ### Fixed 216 | 217 | - Nothing. 218 | 219 | ## 1.2.1 - 2017-03-02 220 | 221 | ### Added 222 | 223 | - Nothing. 224 | 225 | ### Deprecated 226 | 227 | - Nothing. 228 | 229 | ### Removed 230 | 231 | - Nothing. 232 | 233 | ### Fixed 234 | 235 | - [#15](https://github.com/zendframework/zend-expressive-platesrenderer/pull/15) 236 | updates the import statement for exceptions to point to the correct 237 | `Zend\Expressive\Router\Exception` namespace. 238 | 239 | ## 1.2.0 - 2017-01-11 240 | 241 | ### Added 242 | 243 | - [#11](https://github.com/zendframework/zend-expressive-platesrenderer/pull/11) 244 | adds support for zend-expressive-helpers 3.0.0 (and, consequently, 245 | zend-expressive-router 2.0.0). Users may now pass additional arguments to the 246 | `url()` helper: 247 | 248 | ```php 249 | echo $this->url( 250 | $routeName, // (optional) string route name; omit to use current matched route 251 | $routeParams, // (optional) array of route parameter substitutions 252 | $queryParams, // (optional) array of query string parameters to include 253 | $fragmentIdentifer, // (optional) string fragment to include 254 | $options, // (optional) array of options; `router` array will be 255 | // passed to the router, `reuse_result_params` can be 256 | // passed to disable reuse of matched route parameters. 257 | ); 258 | ``` 259 | 260 | If you are still using the zend-expressive-helpers 2.2 series and/or 261 | zend-expressive-router 1.0 series, all parameters provided after the 262 | `$routeParams` will be ignored. 263 | 264 | ### Deprecated 265 | 266 | - Nothing. 267 | 268 | ### Removed 269 | 270 | - [#14](https://github.com/zendframework/zend-expressive-platesrenderer/pull/14) 271 | removes support for PHP 5.5. 272 | 273 | ### Fixed 274 | 275 | - Nothing. 276 | 277 | ## 1.1.1 - 2017-01-11 278 | 279 | ### Added 280 | 281 | - Nothing. 282 | 283 | ### Deprecated 284 | 285 | - Nothing. 286 | 287 | ### Removed 288 | 289 | - Nothing. 290 | 291 | ### Fixed 292 | 293 | - [#9](https://github.com/zendframework/zend-expressive-platesrenderer/pull/9) and 294 | [#13](https://github.com/zendframework/zend-expressive-platesrenderer/pull/13) 295 | update the `PlatesEngineFactory` to ensure it raises a 296 | `Zend\Expressive\Plates\Exception\InvalidExtensionException` if a named 297 | service or an invokable extension class result in a non-`ExtensionInterface` 298 | instance. 299 | 300 | ## 1.1.0 - 2016-03-29 301 | 302 | ### Added 303 | 304 | - [#7](https://github.com/zendframework/zend-expressive-platesrenderer/pull/7) 305 | adds: 306 | - `Zend\Expressive\Plates\PlatesEngineFactory`, which will create and return a 307 | `League\Plates\Engine` instance. It introspects the `plates.extensions` 308 | configuration to optionally load extensions into the engine; that value must 309 | be an array of: 310 | - extension instances 311 | - string service names resolving to extension instances 312 | - string class names resolving to extension instances 313 | - `Zend\Expressive\Plates\Extension\UrlExtension`, which provides a wrapper 314 | around the `UrlHelper` and `ServerUrlHelper` from zend-expressive-helpers, 315 | as the functions `url($route = null, array $params = []) : string` and 316 | `serverurl($path = null) : string`, respectively. 317 | - `Zend\Expressive\Plates\Extension\UrlExtensionFactory`, which provides a 318 | factory for creating the `UrlExtension`. 319 | 320 | ### Deprecated 321 | 322 | - Nothing. 323 | 324 | ### Removed 325 | 326 | - Nothing. 327 | 328 | ### Fixed 329 | 330 | - [#7](https://github.com/zendframework/zend-expressive-platesrenderer/pull/7) 331 | updates `PlatesRendererFactory` to use either the `League\Plates\Engine` 332 | service, if available, or the new `PlatesEngineFactory` to create the Plates 333 | engine instance. This also ensures the `url()` and `serverurl()` functions are 334 | registered by default. 335 | 336 | ## 1.0.0 - 2015-12-07 337 | 338 | First stable release. 339 | 340 | ### Added 341 | 342 | - Nothing. 343 | 344 | ### Deprecated 345 | 346 | - Nothing. 347 | 348 | ### Removed 349 | 350 | - Nothing. 351 | 352 | ### Fixed 353 | 354 | - Nothing. 355 | 356 | ## 0.3.0 - 2015-12-02 357 | 358 | ### Added 359 | 360 | - Nothing. 361 | 362 | ### Deprecated 363 | 364 | - Nothing. 365 | 366 | ### Removed 367 | 368 | - Nothing. 369 | 370 | ### Fixed 371 | 372 | - Now depends on [zendframework/zend-expressive-template](https://github.com/zendframework/zend-expressive-template) 373 | instead of zendframework/zend-expressive. 374 | 375 | ## 0.2.0 - 2015-10-20 376 | 377 | ### Added 378 | 379 | - Nothing. 380 | 381 | ### Deprecated 382 | 383 | - Nothing. 384 | 385 | ### Removed 386 | 387 | - Nothing. 388 | 389 | ### Fixed 390 | 391 | - Updated zend-expressive to RC1. 392 | - Added branch alias for dev-master, pointing to 1.0-dev. 393 | 394 | ## 0.1.0 - 2015-10-10 395 | 396 | Initial release. 397 | 398 | ### Added 399 | 400 | - Nothing. 401 | 402 | ### Deprecated 403 | 404 | - Nothing. 405 | 406 | ### Removed 407 | 408 | - Nothing. 409 | 410 | ### Fixed 411 | 412 | - Nothing. 413 | --------------------------------------------------------------------------------