Gregwar\RST\Parser::getSubParser PHP Метод

getSubParser() публичный Метод

Get a parser with the same environment that this one
public getSubParser ( ) : Parser
Результат Parser a new parser with the same environment
    public function getSubParser()
    {
        return new Parser($this->environment, $this->kernel);
    }

Usage Example

Пример #1
0
 /**
  * Process a directive that should parces the next node as a "sub" document
  */
 public final function process(Parser $parser, $node, $variable, $data, array $options)
 {
     $subParser = $parser->getSubParser();
     if ($node instanceof CodeNode) {
         $document = $subParser->parseLocal($node->getValue());
     } else {
         $document = $node;
     }
     $newNode = $this->processSub($parser, $document, $variable, $data, $options);
     if ($newNode) {
         if ($variable) {
             $parser->getEnvironment()->setVariable($variable, $newNode);
         } else {
             $parser->getDocument()->addNode($newNode);
         }
     }
 }