Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/sitepres.../lib/twig/src/Loader
File: ChainLoader.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/*
[2] Fix | Delete
* This file is part of Twig.
[3] Fix | Delete
*
[4] Fix | Delete
* (c) Fabien Potencier
[5] Fix | Delete
*
[6] Fix | Delete
* For the full copyright and license information, please view the LICENSE
[7] Fix | Delete
* file that was distributed with this source code.
[8] Fix | Delete
*/
[9] Fix | Delete
namespace WPML\Core\Twig\Loader;
[10] Fix | Delete
[11] Fix | Delete
use WPML\Core\Twig\Error\LoaderError;
[12] Fix | Delete
use WPML\Core\Twig\Source;
[13] Fix | Delete
/**
[14] Fix | Delete
* Loads templates from other loaders.
[15] Fix | Delete
*
[16] Fix | Delete
* @final
[17] Fix | Delete
*
[18] Fix | Delete
* @author Fabien Potencier <fabien@symfony.com>
[19] Fix | Delete
*/
[20] Fix | Delete
class ChainLoader implements \WPML\Core\Twig\Loader\LoaderInterface, \WPML\Core\Twig\Loader\ExistsLoaderInterface, \WPML\Core\Twig\Loader\SourceContextLoaderInterface
[21] Fix | Delete
{
[22] Fix | Delete
private $hasSourceCache = [];
[23] Fix | Delete
protected $loaders = [];
[24] Fix | Delete
/**
[25] Fix | Delete
* @param LoaderInterface[] $loaders
[26] Fix | Delete
*/
[27] Fix | Delete
public function __construct(array $loaders = [])
[28] Fix | Delete
{
[29] Fix | Delete
foreach ($loaders as $loader) {
[30] Fix | Delete
$this->addLoader($loader);
[31] Fix | Delete
}
[32] Fix | Delete
}
[33] Fix | Delete
public function addLoader(\WPML\Core\Twig\Loader\LoaderInterface $loader)
[34] Fix | Delete
{
[35] Fix | Delete
$this->loaders[] = $loader;
[36] Fix | Delete
$this->hasSourceCache = [];
[37] Fix | Delete
}
[38] Fix | Delete
/**
[39] Fix | Delete
* @return LoaderInterface[]
[40] Fix | Delete
*/
[41] Fix | Delete
public function getLoaders()
[42] Fix | Delete
{
[43] Fix | Delete
return $this->loaders;
[44] Fix | Delete
}
[45] Fix | Delete
public function getSource($name)
[46] Fix | Delete
{
[47] Fix | Delete
@\trigger_error(\sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', \get_class($this)), \E_USER_DEPRECATED);
[48] Fix | Delete
$exceptions = [];
[49] Fix | Delete
foreach ($this->loaders as $loader) {
[50] Fix | Delete
if ($loader instanceof \WPML\Core\Twig\Loader\ExistsLoaderInterface && !$loader->exists($name)) {
[51] Fix | Delete
continue;
[52] Fix | Delete
}
[53] Fix | Delete
try {
[54] Fix | Delete
return $loader->getSource($name);
[55] Fix | Delete
} catch (\WPML\Core\Twig\Error\LoaderError $e) {
[56] Fix | Delete
$exceptions[] = $e->getMessage();
[57] Fix | Delete
}
[58] Fix | Delete
}
[59] Fix | Delete
throw new \WPML\Core\Twig\Error\LoaderError(\sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' (' . \implode(', ', $exceptions) . ')' : ''));
[60] Fix | Delete
}
[61] Fix | Delete
public function getSourceContext($name)
[62] Fix | Delete
{
[63] Fix | Delete
$exceptions = [];
[64] Fix | Delete
foreach ($this->loaders as $loader) {
[65] Fix | Delete
if ($loader instanceof \WPML\Core\Twig\Loader\ExistsLoaderInterface && !$loader->exists($name)) {
[66] Fix | Delete
continue;
[67] Fix | Delete
}
[68] Fix | Delete
try {
[69] Fix | Delete
if ($loader instanceof \WPML\Core\Twig\Loader\SourceContextLoaderInterface) {
[70] Fix | Delete
return $loader->getSourceContext($name);
[71] Fix | Delete
}
[72] Fix | Delete
return new \WPML\Core\Twig\Source($loader->getSource($name), $name);
[73] Fix | Delete
} catch (\WPML\Core\Twig\Error\LoaderError $e) {
[74] Fix | Delete
$exceptions[] = $e->getMessage();
[75] Fix | Delete
}
[76] Fix | Delete
}
[77] Fix | Delete
throw new \WPML\Core\Twig\Error\LoaderError(\sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' (' . \implode(', ', $exceptions) . ')' : ''));
[78] Fix | Delete
}
[79] Fix | Delete
public function exists($name)
[80] Fix | Delete
{
[81] Fix | Delete
$name = (string) $name;
[82] Fix | Delete
if (isset($this->hasSourceCache[$name])) {
[83] Fix | Delete
return $this->hasSourceCache[$name];
[84] Fix | Delete
}
[85] Fix | Delete
foreach ($this->loaders as $loader) {
[86] Fix | Delete
if ($loader instanceof \WPML\Core\Twig\Loader\ExistsLoaderInterface) {
[87] Fix | Delete
if ($loader->exists($name)) {
[88] Fix | Delete
return $this->hasSourceCache[$name] = \true;
[89] Fix | Delete
}
[90] Fix | Delete
continue;
[91] Fix | Delete
}
[92] Fix | Delete
try {
[93] Fix | Delete
if ($loader instanceof \WPML\Core\Twig\Loader\SourceContextLoaderInterface) {
[94] Fix | Delete
$loader->getSourceContext($name);
[95] Fix | Delete
} else {
[96] Fix | Delete
$loader->getSource($name);
[97] Fix | Delete
}
[98] Fix | Delete
return $this->hasSourceCache[$name] = \true;
[99] Fix | Delete
} catch (\WPML\Core\Twig\Error\LoaderError $e) {
[100] Fix | Delete
}
[101] Fix | Delete
}
[102] Fix | Delete
return $this->hasSourceCache[$name] = \false;
[103] Fix | Delete
}
[104] Fix | Delete
public function getCacheKey($name)
[105] Fix | Delete
{
[106] Fix | Delete
$exceptions = [];
[107] Fix | Delete
foreach ($this->loaders as $loader) {
[108] Fix | Delete
if ($loader instanceof \WPML\Core\Twig\Loader\ExistsLoaderInterface && !$loader->exists($name)) {
[109] Fix | Delete
continue;
[110] Fix | Delete
}
[111] Fix | Delete
try {
[112] Fix | Delete
return $loader->getCacheKey($name);
[113] Fix | Delete
} catch (\WPML\Core\Twig\Error\LoaderError $e) {
[114] Fix | Delete
$exceptions[] = \get_class($loader) . ': ' . $e->getMessage();
[115] Fix | Delete
}
[116] Fix | Delete
}
[117] Fix | Delete
throw new \WPML\Core\Twig\Error\LoaderError(\sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' (' . \implode(', ', $exceptions) . ')' : ''));
[118] Fix | Delete
}
[119] Fix | Delete
public function isFresh($name, $time)
[120] Fix | Delete
{
[121] Fix | Delete
$exceptions = [];
[122] Fix | Delete
foreach ($this->loaders as $loader) {
[123] Fix | Delete
if ($loader instanceof \WPML\Core\Twig\Loader\ExistsLoaderInterface && !$loader->exists($name)) {
[124] Fix | Delete
continue;
[125] Fix | Delete
}
[126] Fix | Delete
try {
[127] Fix | Delete
return $loader->isFresh($name, $time);
[128] Fix | Delete
} catch (\WPML\Core\Twig\Error\LoaderError $e) {
[129] Fix | Delete
$exceptions[] = \get_class($loader) . ': ' . $e->getMessage();
[130] Fix | Delete
}
[131] Fix | Delete
}
[132] Fix | Delete
throw new \WPML\Core\Twig\Error\LoaderError(\sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' (' . \implode(', ', $exceptions) . ')' : ''));
[133] Fix | Delete
}
[134] Fix | Delete
}
[135] Fix | Delete
\class_alias('WPML\\Core\\Twig\\Loader\\ChainLoader', 'WPML\\Core\\Twig_Loader_Chain');
[136] Fix | Delete
[137] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function