/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/twig-view/src/Twig
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/twig-view/src/Twig/FileLoader.php (3687B)
extensions = $extensions;
}
/**
* @inheritDoc
*/
public function getSourceContext(string $name): Source
{
$path = $this->findTemplate($name);
return new Source(file_get_contents($path), $name, $path);
}
/**
* @inheritDoc
*/
public function getCacheKey(string $name): string
{
return $this->findTemplate($name);
}
/**
* @inheritDoc
*/
public function isFresh(string $name, int $time): bool
{
$path = $this->findTemplate($name);
return filemtime($path) < $time;
}
/**
* @inheritDoc
*/
public function exists(string $name)
{
try {
$this->findTemplate($name);
} catch (LoaderError $e) {
return false;
}
return true;
}
/**
* @param string $name Template name
* @return string
*/
public function findTemplate(string $name): string
{
if (file_exists($name)) {
return $name;
}
[$plugin, $name] = pluginSplit($name);
$name = str_replace('/', DIRECTORY_SEPARATOR, $name);
if ($plugin !== null) {
$templatePath = Plugin::templatePath($plugin);
$path = $this->checkExtensions($templatePath . $name);
if ($path !== null) {
return $path;
}
$error = "Could not find template `{$name}` in plugin `{$plugin}` in these paths:\n\n"
. "- `{$templatePath}`\n";
throw new LoaderError($error);
}
foreach (App::path('templates') as $templatePath) {
$path = $this->checkExtensions($templatePath . $name);
if ($path !== null) {
return $path;
}
}
$error = "Could not find template `{$name}` in these paths:\n\n";
foreach (App::path('templates') as $templatePath) {
$error .= "- `{$templatePath}`\n";
}
throw new LoaderError($error);
}
/**
* Check partial path with all template file extensions to see
* which file exists.
*
* @param string $partial Template path excluding extension
* @return string|null
*/
public function checkExtensions(string $partial): ?string
{
foreach ($this->extensions as $extension) {
$path = $partial . $extension;
if (file_exists($path)) {
return $path;
}
}
return null;
}
}