/**
  * Returns the built-in set of ViewHelper classes with
  * one addition, `f:myLink` which is redirected to anoter
  * class.
  *
  * @param string $namespaceIdentifier
  * @param string $methodIdentifier
  * @return NULL|string
  */
 public function resolveViewHelperClassName($namespaceIdentifier, $methodIdentifier)
 {
     if ($namespaceIdentifier === 'f' && $methodIdentifier === 'myLink') {
         return 'NamelessCoder\\FluidExample\\ViewHelpers\\CustomViewHelper';
     }
     return parent::resolveViewHelperClassName($namespaceIdentifier, $methodIdentifier);
 }
Ejemplo n.º 2
0
 /**
  * Constructor.
  *
  * @param ViewHelperResolver an instance or subclass of ViewHelperResolver
  * @param string $namespace the namespace identifier of the ViewHelper.
  * @param string $identifier the name of the ViewHelper to render, inside the namespace provided.
  * @param NodeInterface[] $arguments Arguments of view helper - each value is a RootNode.
  * @param ParsingState $state
  */
 public function __construct(ViewHelperResolver $resolver, $namespace, $identifier, array $arguments, ParsingState $state)
 {
     $this->viewHelperResolver = $resolver;
     $this->viewHelperClassName = $resolver->resolveViewHelperClassName($namespace, $identifier);
     $this->uninitializedViewHelper = $resolver->createViewHelperInstance($namespace, $identifier);
     $this->arguments = $arguments;
     $this->argumentDefinitions = $resolver->getArgumentDefinitionsForViewHelper($this->uninitializedViewHelper);
     $this->rewriteBooleanNodesInArgumentsObjectTree($this->argumentDefinitions, $this->arguments);
 }
Ejemplo n.º 3
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)
 {
     if ($this->viewHelperResolver->isNamespaceValid($namespaceIdentifier, $methodIdentifier) === FALSE) {
         return FALSE;
     }
     $lastStackElement = $state->popNodeFromStack();
     if (!$lastStackElement instanceof ViewHelperNode) {
         throw new Exception('You closed a templating tag which you never opened!', 1224485838);
     }
     $actualViewHelperClassName = $this->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;
 }