File "DirResolver.php"
Full Path: /home/siazco/grocery.siazco.se/wp-content/plugins/flexible-shipping-pro/vendor_prefixed/wpdesk/wp-view/src/Resolver/DirResolver.php
File size: 1.06 KB
MIME-type: text/x-php
Charset: utf-8
<?php
namespace FSProVendor\WPDesk\View\Resolver;
use FSProVendor\WPDesk\View\Renderer\Renderer;
use FSProVendor\WPDesk\View\Resolver\Exception\CanNotResolve;
/**
* Class should resolve name by serching in provided dir. If empty then current dir
*
* @package WPDesk\View\Resolver
*/
class DirResolver implements \FSProVendor\WPDesk\View\Resolver\Resolver
{
/** @var string */
private $dir;
/**
* Base path for templates ie. subdir
*
* @param $dir
*/
public function __construct($dir)
{
$this->dir = $dir;
}
/**
* Resolve name to full path
*
* @param string $name
* @param Renderer|null $renderer
*
* @return string
*/
public function resolve($name, \FSProVendor\WPDesk\View\Renderer\Renderer $renderer = null)
{
$dir = \rtrim($this->dir, '/');
$fullName = $dir . '/' . $name;
if (\file_exists($fullName)) {
return $fullName;
}
throw new \FSProVendor\WPDesk\View\Resolver\Exception\CanNotResolve("Cannot resolve {$name}");
}
}