ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Twig_TokenParserBroker Class Reference

Default implementation of a token parser broker. More...

+ Inheritance diagram for Twig_TokenParserBroker:
+ Collaboration diagram for Twig_TokenParserBroker:

Public Member Functions

 __construct ($parsers=array(), $brokers=array(), $triggerDeprecationError=true)
 
 addTokenParser (Twig_TokenParserInterface $parser)
 
 removeTokenParser (Twig_TokenParserInterface $parser)
 
 addTokenParserBroker (self $broker)
 
 removeTokenParserBroker (self $broker)
 
 getTokenParser ($tag)
 Gets a suitable TokenParser for a tag. More...
 
 getParsers ()
 
 getParser ()
 Gets the Twig_ParserInterface. More...
 
 setParser (Twig_ParserInterface $parser)
 Calls Twig_TokenParserInterface::setParser on all parsers the implementation knows of. More...
 

Protected Attributes

 $parser
 
 $parsers = array()
 
 $brokers = array()
 

Detailed Description

Default implementation of a token parser broker.

Author
Arnaud Le Blanc arnau.nosp@m.d.lb.nosp@m.@gmai.nosp@m.l.co.nosp@m.m
Deprecated:
since 1.12 (to be removed in 2.0)

Definition at line 20 of file TokenParserBroker.php.

Constructor & Destructor Documentation

◆ __construct()

Twig_TokenParserBroker::__construct (   $parsers = array(),
  $brokers = array(),
  $triggerDeprecationError = true 
)
Parameters
array | Traversable$parsersA Traversable of Twig_TokenParserInterface instances
array | Traversable$brokersA Traversable of Twig_TokenParserBrokerInterface instances
bool$triggerDeprecationError

Definition at line 31 of file TokenParserBroker.php.

References $brokers, $parser, and $parsers.

32  {
33  if ($triggerDeprecationError) {
34  @trigger_error('The '.__CLASS__.' class is deprecated since version 1.12 and will be removed in 2.0.', E_USER_DEPRECATED);
35  }
36 
37  foreach ($parsers as $parser) {
38  if (!$parser instanceof Twig_TokenParserInterface) {
39  throw new LogicException('$parsers must a an array of Twig_TokenParserInterface.');
40  }
41  $this->parsers[$parser->getTag()] = $parser;
42  }
43  foreach ($brokers as $broker) {
44  if (!$broker instanceof Twig_TokenParserBrokerInterface) {
45  throw new LogicException('$brokers must a an array of Twig_TokenParserBrokerInterface.');
46  }
47  $this->brokers[] = $broker;
48  }
49  }
Interface implemented by token parser brokers.
Interface implemented by token parsers.

Member Function Documentation

◆ addTokenParser()

Twig_TokenParserBroker::addTokenParser ( Twig_TokenParserInterface  $parser)

Definition at line 51 of file TokenParserBroker.php.

References $parser, and Twig_TokenParserInterface\getTag().

52  {
53  $this->parsers[$parser->getTag()] = $parser;
54  }
getTag()
Gets the tag name associated with this token parser.
+ Here is the call graph for this function:

◆ addTokenParserBroker()

Twig_TokenParserBroker::addTokenParserBroker ( self  $broker)

Definition at line 64 of file TokenParserBroker.php.

65  {
66  $this->brokers[] = $broker;
67  }

◆ getParser()

Twig_TokenParserBroker::getParser ( )

Gets the Twig_ParserInterface.

Returns
null|Twig_ParserInterface A Twig_ParserInterface instance or null

Implements Twig_TokenParserBrokerInterface.

Definition at line 105 of file TokenParserBroker.php.

References $parser.

106  {
107  return $this->parser;
108  }

◆ getParsers()

Twig_TokenParserBroker::getParsers ( )

Definition at line 100 of file TokenParserBroker.php.

References $parsers.

101  {
102  return $this->parsers;
103  }

◆ getTokenParser()

Twig_TokenParserBroker::getTokenParser (   $tag)

Gets a suitable TokenParser for a tag.

First looks in parsers, then in brokers.

Parameters
string$tagA tag name
Returns
null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable TokenParser was found

Implements Twig_TokenParserBrokerInterface.

Definition at line 85 of file TokenParserBroker.php.

References $parser, and $tag.

86  {
87  if (isset($this->parsers[$tag])) {
88  return $this->parsers[$tag];
89  }
90  $broker = end($this->brokers);
91  while (false !== $broker) {
92  $parser = $broker->getTokenParser($tag);
93  if (null !== $parser) {
94  return $parser;
95  }
96  $broker = prev($this->brokers);
97  }
98  }
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35

◆ removeTokenParser()

Twig_TokenParserBroker::removeTokenParser ( Twig_TokenParserInterface  $parser)

Definition at line 56 of file TokenParserBroker.php.

References $name, and Twig_TokenParserInterface\getTag().

57  {
58  $name = $parser->getTag();
59  if (isset($this->parsers[$name]) && $parser === $this->parsers[$name]) {
60  unset($this->parsers[$name]);
61  }
62  }
getTag()
Gets the tag name associated with this token parser.
if($format !==null) $name
Definition: metadata.php:146
+ Here is the call graph for this function:

◆ removeTokenParserBroker()

Twig_TokenParserBroker::removeTokenParserBroker ( self  $broker)

Definition at line 69 of file TokenParserBroker.php.

70  {
71  if (false !== $pos = array_search($broker, $this->brokers)) {
72  unset($this->brokers[$pos]);
73  }
74  }

◆ setParser()

Twig_TokenParserBroker::setParser ( Twig_ParserInterface  $parser)

Calls Twig_TokenParserInterface::setParser on all parsers the implementation knows of.

Implements Twig_TokenParserBrokerInterface.

Definition at line 110 of file TokenParserBroker.php.

References $parser.

111  {
112  $this->parser = $parser;
113  foreach ($this->parsers as $tokenParser) {
114  $tokenParser->setParser($parser);
115  }
116  foreach ($this->brokers as $broker) {
117  $broker->setParser($parser);
118  }
119  }

Field Documentation

◆ $brokers

Twig_TokenParserBroker::$brokers = array()
protected

Definition at line 24 of file TokenParserBroker.php.

Referenced by __construct().

◆ $parser

Twig_TokenParserBroker::$parser
protected

◆ $parsers

Twig_TokenParserBroker::$parsers = array()
protected

Definition at line 23 of file TokenParserBroker.php.

Referenced by __construct(), and getParsers().


The documentation for this class was generated from the following file: