Ejemplo n.º 1
0
 /**
  * @test
  */
 public function pushAndGetFromStackWorks()
 {
     $rootNode = new RootNode();
     $this->parsingState->pushNodeToStack($rootNode);
     $this->assertSame($rootNode, $this->parsingState->getNodeFromStack($rootNode), 'Node returned from stack was not the right one.');
     $this->assertSame($rootNode, $this->parsingState->popNodeFromStack($rootNode), 'Node popped from stack was not the right one.');
 }
Ejemplo n.º 2
0
 /**
  * Handles a closing view helper tag
  *
  * @param ParsingState $state The current parsing state
  * @param string $namespaceIdentifier Namespace identifier for the closing tag.
  * @param string $methodIdentifier Method identifier.
  * @return boolean whether the viewHelper was found and added to the stack or not
  * @throws Exception
  */
 protected function closingViewHelperTagHandler(ParsingState $state, $namespaceIdentifier, $methodIdentifier)
 {
     $viewHelperResolver = $this->renderingContext->getViewHelperResolver();
     if (!$viewHelperResolver->isNamespaceValid($namespaceIdentifier)) {
         return FALSE;
     }
     $lastStackElement = $state->popNodeFromStack();
     if (!$lastStackElement instanceof ViewHelperNode) {
         throw new Exception('You closed a templating tag which you never opened!', 1224485838);
     }
     $actualViewHelperClassName = $viewHelperResolver->resolveViewHelperClassName($namespaceIdentifier, $methodIdentifier);
     $expectedViewHelperClassName = $lastStackElement->getViewHelperClassName();
     if ($actualViewHelperClassName !== $expectedViewHelperClassName) {
         throw new Exception('Templating tags not properly nested. Expected: ' . $expectedViewHelperClassName . '; Actual: ' . $actualViewHelperClassName, 1224485398);
     }
     $this->callInterceptor($lastStackElement, InterceptorInterface::INTERCEPT_CLOSING_VIEWHELPER, $state);
     $state->getNodeFromStack()->addChildNode($lastStackElement);
     return TRUE;
 }