68 lines
1.6 KiB
PHP
68 lines
1.6 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\Component\Templating\Loader;
|
|
|
|
use Symfony\Component\Templating\Storage\Storage;
|
|
use Symfony\Component\Templating\TemplateReferenceInterface;
|
|
|
|
trigger_deprecation('symfony/templating', '6.4', '"%s" is deprecated since version 6.4 and will be removed in 7.0. Use Twig instead.', ChainLoader::class);
|
|
|
|
/**
|
|
* ChainLoader is a loader that calls other loaders to load templates.
|
|
*
|
|
* @author Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* @deprecated since Symfony 6.4, use Twig instead
|
|
*/
|
|
class ChainLoader extends Loader
|
|
{
|
|
protected $loaders = [];
|
|
|
|
/**
|
|
* @param LoaderInterface[] $loaders
|
|
*/
|
|
public function __construct(array $loaders = [])
|
|
{
|
|
foreach ($loaders as $loader) {
|
|
$this->addLoader($loader);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return void
|
|
*/
|
|
public function addLoader(LoaderInterface $loader)
|
|
{
|
|
$this->loaders[] = $loader;
|
|
}
|
|
|
|
public function load(TemplateReferenceInterface $template): Storage|false
|
|
{
|
|
foreach ($this->loaders as $loader) {
|
|
if (false !== $storage = $loader->load($template)) {
|
|
return $storage;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public function isFresh(TemplateReferenceInterface $template, int $time): bool
|
|
{
|
|
foreach ($this->loaders as $loader) {
|
|
return $loader->isFresh($template, $time);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|