HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/azvo/wp-content/plugins/sitepress-multilingual-cms/lib/twig/lib/Twig/TokenParserBroker.php
<?php

namespace WPML\Core;

/*
 * This file is part of Twig.
 *
 * (c) Fabien Potencier
 * (c) Arnaud Le Blanc
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
use WPML\Core\Twig\TokenParser\TokenParserInterface;
/**
 * Default implementation of a token parser broker.
 *
 * @author Arnaud Le Blanc <arnaud.lb@gmail.com>
 *
 * @deprecated since 1.12 (to be removed in 2.0)
 */
class Twig_TokenParserBroker implements \WPML\Core\Twig_TokenParserBrokerInterface
{
    protected $parser;
    protected $parsers = [];
    protected $brokers = [];
    /**
     * @param array|\Traversable $parsers                 A \Traversable of Twig_TokenParserInterface instances
     * @param array|\Traversable $brokers                 A \Traversable of Twig_TokenParserBrokerInterface instances
     * @param bool               $triggerDeprecationError
     */
    public function __construct($parsers = [], $brokers = [], $triggerDeprecationError = \true)
    {
        if ($triggerDeprecationError) {
            @\trigger_error('The ' . __CLASS__ . ' class is deprecated since version 1.12 and will be removed in 2.0.', \E_USER_DEPRECATED);
        }
        foreach ($parsers as $parser) {
            if (!$parser instanceof \WPML\Core\Twig\TokenParser\TokenParserInterface) {
                throw new \LogicException('$parsers must a an array of Twig_TokenParserInterface.');
            }
            $this->parsers[$parser->getTag()] = $parser;
        }
        foreach ($brokers as $broker) {
            if (!$broker instanceof \WPML\Core\Twig_TokenParserBrokerInterface) {
                throw new \LogicException('$brokers must a an array of Twig_TokenParserBrokerInterface.');
            }
            $this->brokers[] = $broker;
        }
    }
    public function addTokenParser(\WPML\Core\Twig\TokenParser\TokenParserInterface $parser)
    {
        $this->parsers[$parser->getTag()] = $parser;
    }
    public function removeTokenParser(\WPML\Core\Twig\TokenParser\TokenParserInterface $parser)
    {
        $name = $parser->getTag();
        if (isset($this->parsers[$name]) && $parser === $this->parsers[$name]) {
            unset($this->parsers[$name]);
        }
    }
    public function addTokenParserBroker(self $broker)
    {
        $this->brokers[] = $broker;
    }
    public function removeTokenParserBroker(self $broker)
    {
        if (\false !== ($pos = \array_search($broker, $this->brokers))) {
            unset($this->brokers[$pos]);
        }
    }
    /**
     * Gets a suitable TokenParser for a tag.
     *
     * First looks in parsers, then in brokers.
     *
     * @param string $tag A tag name
     *
     * @return TokenParserInterface|null A Twig_TokenParserInterface or null if no suitable TokenParser was found
     */
    public function getTokenParser($tag)
    {
        if (isset($this->parsers[$tag])) {
            return $this->parsers[$tag];
        }
        $broker = \end($this->brokers);
        while (\false !== $broker) {
            $parser = $broker->getTokenParser($tag);
            if (null !== $parser) {
                return $parser;
            }
            $broker = \prev($this->brokers);
        }
    }
    public function getParsers()
    {
        return $this->parsers;
    }
    public function getParser()
    {
        return $this->parser;
    }
    public function setParser(\WPML\Core\Twig_ParserInterface $parser)
    {
        $this->parser = $parser;
        foreach ($this->parsers as $tokenParser) {
            $tokenParser->setParser($parser);
        }
        foreach ($this->brokers as $broker) {
            $broker->setParser($parser);
        }
    }
}