You are here

public function Twig_TokenParserBroker::getTokenParser in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/twig/twig/lib/Twig/TokenParserBroker.php \Twig_TokenParserBroker::getTokenParser()

Gets a suitable TokenParser for a tag.

First looks in parsers, then in brokers.

Parameters

string $tag A tag name:

Return value

null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable TokenParser was found

Overrides Twig_TokenParserBrokerInterface::getTokenParser

File

vendor/twig/twig/lib/Twig/TokenParserBroker.php, line 107

Class

Twig_TokenParserBroker
Default implementation of a token parser broker.

Code

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);
  }
}