Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
wp-content
/
plugins
/
flexible-shipping
/
vendor_prefixed
/
wpdesk
/
wp-view
/
src
/
Resolver
:
ChainResolver.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace FSVendor\WPDesk\View\Resolver; use FSVendor\WPDesk\View\Renderer\Renderer; use FSVendor\WPDesk\View\Resolver\Exception\CanNotResolve; /** * Provide resolvers and this class can try them one after another * * @package WPDesk\View\Resolver */ class ChainResolver implements Resolver { /** @var Resolver[] */ private $resolvers; /** * Warning: function with variadic input. Input should be list of Resolver instances. */ public function __construct() { $args = func_get_args(); foreach ($args as $resolver) { $this->appendResolver($resolver); } } /** * Append resolver to the end of the list * * @param Resolver $resolver */ public function appendResolver($resolver) { $this->resolvers[] = $resolver; } /** * Resolve name to full path * * @param string $name * @param Renderer|null $renderer * * @return string */ public function resolve($name, Renderer $renderer = null) { foreach ($this->resolvers as $resolver) { try { return $resolver->resolve($name); } catch (CanNotResolve $e) { // not interested } } throw new CanNotResolve("Cannot resolve {$name}"); } }