/** * Handles the appearance of an object accessor (like {posts.author.email}). * Creates a new instance of \F3\Fluid\ObjectAccessorNode. * * Handles ViewHelpers as well which are in the shorthand syntax. * * @param \F3\Fluid\Core\Parser\ParsingState $state The current parsing state * @param string $objectAccessorString String which identifies which objects to fetch * @return void * @author Sebastian Kurfürst <*****@*****.**> */ protected function objectAccessorHandler(\F3\Fluid\Core\Parser\ParsingState $state, $objectAccessorString, $delimiter, $viewHelperString, $additionalViewHelpersString) { $viewHelperString .= $additionalViewHelpersString; $numberOfViewHelpers = 0; // The following post-processing handles a case when there is only a ViewHelper, and no Object Accessor. // Resolves bug #5107. if (strlen($delimiter) === 0 && strlen($viewHelperString) > 0) { $viewHelperString = $objectAccessorString . $viewHelperString; $objectAccessorString = ''; } // ViewHelpers $matches = array(); if (strlen($viewHelperString) > 0 && preg_match_all(self::$SPLIT_PATTERN_SHORTHANDSYNTAX_VIEWHELPER, $viewHelperString, $matches, PREG_SET_ORDER) > 0) { // The last ViewHelper has to be added first for correct chaining. $matches = array_reverse($matches); foreach ($matches as $singleMatch) { $namespaceIdentifier = $singleMatch['NamespaceIdentifier']; $methodIdentifier = $singleMatch['MethodIdentifier']; if (strlen($singleMatch['ViewHelperArguments']) > 0) { $arguments = $this->recursiveArrayHandler($singleMatch['ViewHelperArguments']); $arguments = $this->postProcessArgumentsForObjectAccessor($arguments); } else { $arguments = array(); } $this->initializeViewHelperAndAddItToStack($state, $namespaceIdentifier, $methodIdentifier, $arguments); $numberOfViewHelpers++; } } // Object Accessor if (strlen($objectAccessorString) > 0) { $node = $this->objectFactory->create('F3\\Fluid\\Core\\Parser\\SyntaxTree\\ObjectAccessorNode', $objectAccessorString); if ($this->configuration !== NULL) { foreach ($this->configuration->getValueInterceptors() as $interceptor) { $node = $interceptor->process($node); } } $state->getNodeFromStack()->addChildNode($node); } // Close ViewHelper Tags if needed. for ($i = 0; $i < $numberOfViewHelpers; $i++) { $state->popNodeFromStack(); } }