upgrade zend (#1559)
[openemr.git] / vendor / zendframework / zend-view / src / Resolver / PrefixPathStackResolver.php
blob9ac95aa1a15703c2b13768088e32a04aae6f1794
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\View\Resolver;
12 use Zend\View\Renderer\RendererInterface as Renderer;
14 final class PrefixPathStackResolver implements ResolverInterface
16 /**
17 * Array containing prefix as key and "template path stack array" as value
19 * @var string[]|string[][]|ResolverInterface[]
21 private $prefixes = [];
23 /**
24 * Constructor
26 * @param string[]|string[][]|ResolverInterface[] $prefixes Set of path prefixes to be matched (array keys), with
27 * either a path or an array of paths to use for matching
28 * as in the {@see \Zend\View\Resolver\TemplatePathStack},
29 * or a {@see \Zend\View\Resolver\ResolverInterface}
30 * to use for view path starting with that prefix
32 public function __construct(array $prefixes = [])
34 $this->prefixes = $prefixes;
37 /**
38 * {@inheritDoc}
40 public function resolve($name, Renderer $renderer = null)
42 foreach ($this->prefixes as $prefix => & $resolver) {
43 if (strpos($name, $prefix) !== 0) {
44 continue;
47 if (! $resolver instanceof ResolverInterface) {
48 $resolver = new TemplatePathStack(['script_paths' => (array) $resolver]);
51 if ($result = $resolver->resolve(substr($name, strlen($prefix)), $renderer)) {
52 return $result;
56 return;