예제 #1
0
 /**
  * Build object tree from the split template
  *
  * @param array $splitTemplate The split template, so that every tag with a namespace declaration is already a seperate array element.
  * @param integer $context one of the CONTEXT_* constants, defining whether we are inside or outside of ViewHelper arguments currently.
  * @return ParsingState
  * @throws Exception
  */
 protected function buildObjectTree(array $splitTemplate, $context)
 {
     $state = $this->getParsingState();
     foreach ($splitTemplate as $templateElement) {
         $matchedVariables = array();
         if (preg_match_all(Patterns::$SPLIT_PATTERN_TEMPLATE_OPEN_NAMESPACETAG, $templateElement, $matchedVariables, PREG_SET_ORDER) > 0) {
             foreach ($matchedVariables as $namespaceMatch) {
                 $viewHelperNamespace = $this->unquoteString($namespaceMatch[2]);
                 $phpNamespace = $this->viewHelperResolver->resolvePhpNamespaceFromFluidNamespace($viewHelperNamespace);
                 $this->viewHelperResolver->registerNamespace($namespaceMatch[1], $phpNamespace);
             }
             continue;
         } elseif (trim($templateElement) === '</f:fluid>' || trim($templateElement) === '</fluid>') {
             continue;
         } elseif (preg_match(Patterns::$SCAN_PATTERN_CDATA, $templateElement, $matchedVariables) > 0) {
             $this->textHandler($state, $matchedVariables[1]);
             continue;
         } elseif (preg_match(Patterns::$SCAN_PATTERN_TEMPLATE_VIEWHELPERTAG, $templateElement, $matchedVariables) > 0) {
             $viewHelperWasOpened = $this->openingViewHelperTagHandler($state, $matchedVariables['NamespaceIdentifier'], $matchedVariables['MethodIdentifier'], $matchedVariables['Attributes'], $matchedVariables['Selfclosing'] === '' ? FALSE : TRUE);
             if ($viewHelperWasOpened === TRUE) {
                 continue;
             }
         } elseif (preg_match(Patterns::$SCAN_PATTERN_TEMPLATE_CLOSINGVIEWHELPERTAG, $templateElement, $matchedVariables) > 0) {
             $viewHelperWasClosed = $this->closingViewHelperTagHandler($state, $matchedVariables['NamespaceIdentifier'], $matchedVariables['MethodIdentifier']);
             if ($viewHelperWasClosed === TRUE) {
                 continue;
             }
         }
         $this->textAndShorthandSyntaxHandler($state, $templateElement, $context);
     }
     if ($state->countNodeStack() !== 1) {
         throw new Exception('Not all tags were closed!', 1238169398);
     }
     return $state;
 }
예제 #2
0
 /**
  * @param string $input
  * @param string $expected
  * @test
  * @dataProvider getResolvePhpNamespaceFromFluidNamespaceTestValues
  */
 public function testResolvePhpNamespaceFromFluidNamespace($input, $expected)
 {
     $resolver = new ViewHelperResolver();
     $this->assertEquals($expected, $resolver->resolvePhpNamespaceFromFluidNamespace($input));
 }