/** * @param AbstractViewHelper $viewHelper * @return void */ protected function injectDependenciesIntoViewHelper(AbstractViewHelper $viewHelper) { $viewHelper->setRenderingContext($this->renderingContext); $viewHelper->setArguments($this->arguments); if ($viewHelper instanceof AbstractTagBasedViewHelper) { $viewHelper->injectTagBuilder($this->tagBuilder); } }
/** * @test */ public function processReenablesEscapingInterceptorOnClosingViewHelperTagIfItWasDisabledBefore() { $interceptorPosition = InterceptorInterface::INTERCEPT_CLOSING_VIEWHELPER; $this->mockViewHelper->expects($this->any())->method('isOutputEscapingEnabled')->will($this->returnValue(FALSE)); $this->mockNode->expects($this->any())->method('getUninitializedViewHelper')->will($this->returnValue($this->mockViewHelper)); $this->escapeInterceptor->_set('childrenEscapingEnabled', FALSE); $this->escapeInterceptor->_set('viewHelperNodesWhichDisableTheInterceptor', array($this->mockNode)); $this->escapeInterceptor->process($this->mockNode, $interceptorPosition, $this->mockParsingState); $this->assertTrue($this->escapeInterceptor->_get('childrenEscapingEnabled')); }
/** * @return void */ public function initializeArguments() { parent::initializeArguments(); $this->registerArgument('section', 'string', 'Section to render - combine with partial to render section in partial', FALSE, NULL); $this->registerArgument('partial', 'string', 'Partial to render, with or without section', FALSE, NULL); $this->registerArgument('arguments', 'array', 'Array of variables to be transferred. Use {_all} for all variables', FALSE, array()); $this->registerArgument('optional', 'boolean', 'If TRUE, considers the *section* optional. Partial never is.', FALSE, FALSE); }
/** * @return void */ public function initializeArguments() { parent::initializeArguments(); $this->registerArgument('value', 'string', 'Value to format', FALSE, NULL); $this->registerArgument('keepQuotes', 'boolean', 'If TRUE quotes will not be replaced (ENT_NOQUOTES)', FALSE, FALSE); $this->registerArgument('encoding', 'string', 'Encoding', FALSE, 'UTF-8'); $this->registerArgument('doubleEncode', 'boolean', 'If FALSE html entities will not be encoded', FALSE, TRUE); }
/** * @return void */ public function initializeArguments() { parent::initializeArguments(); $this->registerArgument('each', 'array', 'The array or \\SplObjectStorage to iterated over', TRUE); $this->registerArgument('as', 'string', 'The name of the iteration variable', TRUE); $this->registerArgument('groupBy', 'string', 'Group by this property', TRUE); $this->registerArgument('groupKey', 'string', 'The name of the variable to store the current group', FALSE, 'groupKey'); }
/** * @return void */ public function initializeArguments() { parent::initializeArguments(); $this->registerArgument('each', 'array', 'The array or \\SplObjectStorage to iterated over', TRUE); $this->registerArgument('as', 'string', 'The name of the iteration variable', TRUE); $this->registerArgument('key', 'string', 'Variable to assign array key to', TRUE); $this->registerArgument('reverse', 'boolean', 'If TRUE, iterates in reverse', FALSE, FALSE); $this->registerArgument('iteration', 'string', 'Name of iteration variable to assign', FALSE, NULL); }
/** * @return void */ public function initializeArguments() { parent::initializeArguments(); $this->registerArgument('map', 'array', 'Array that specifies which variables should be mapped to which alias', TRUE); }
/** * @return void */ public function initializeArguments() { parent::initializeArguments(); $this->registerArgument('value', 'mixed', 'Value to match in this case', TRUE); }
/** * @return void */ public function initializeArguments() { parent::initializeArguments(); $this->registerArgument('subject', 'array', 'Countable subject, array or \\Countable', FALSE, NULL); }
/** * @return void */ public function initializeArguments() { parent::initializeArguments(); $this->registerArgument('arguments', 'array', 'The arguments for vsprintf', FALSE, array()); $this->registerArgument('value', 'string', 'String to format', FALSE, FALSE); }
/** * @return void */ public function initializeArguments() { parent::initializeArguments(); $this->registerArgument('expression', 'mixed', 'Expression to switch', TRUE); }
/** * @return void */ public function initializeArguments() { parent::initializeArguments(); $this->registerArgument('values', 'array', 'The array or object implementing \\ArrayAccess (for example \\SplObjectStorage) to iterated over', FALSE); $this->registerArgument('as', 'strong', 'The name of the iteration variable', TRUE); }
/** * @return void */ public function initializeArguments() { parent::initializeArguments(); $this->registerArgument('typeOnly', 'boolean', 'If TRUE, debugs only the type of variables', FALSE, FALSE); }
/** * The compiled ViewHelper adds two new ViewHelper arguments: __thenClosure and __elseClosure. * These contain closures which are be executed to render the then(), respectively else() case. * * @param string $argumentsName * @param string $closureName * @param string $initializationPhpCode * @param ViewHelperNode $node * @param TemplateCompiler $compiler * @return string */ public function compile($argumentsName, $closureName, &$initializationPhpCode, ViewHelperNode $node, TemplateCompiler $compiler) { $thenViewHelperEncountered = $elseViewHelperEncountered = FALSE; foreach ($node->getChildNodes() as $childNode) { if ($childNode instanceof ViewHelperNode) { $viewHelperClassName = $childNode->getViewHelperClassName(); if (substr($viewHelperClassName, -14) === 'ThenViewHelper') { $thenViewHelperEncountered = TRUE; $childNodesAsClosure = $compiler->wrapChildNodesInClosure($childNode); $initializationPhpCode .= sprintf('%s[\'__thenClosure\'] = %s;', $argumentsName, $childNodesAsClosure) . chr(10); } elseif (substr($viewHelperClassName, -14) === 'ElseViewHelper') { $elseViewHelperEncountered = TRUE; $childNodesAsClosure = $compiler->wrapChildNodesInClosure($childNode); $initializationPhpCode .= sprintf('%s[\'__elseClosures\'][] = %s;', $argumentsName, $childNodesAsClosure) . chr(10); $arguments = $childNode->getArguments(); if (isset($arguments['if'])) { // The "else" has an argument, indicating it has a secondary (elseif) condition. // Compile a closure which will evaluate the condition. $elseIfConditionAsClosure = $compiler->wrapViewHelperNodeArgumentEvaluationInClosure($childNode, 'if'); $initializationPhpCode .= sprintf('%s[\'__elseifClosures\'][] = %s;', $argumentsName, $elseIfConditionAsClosure) . chr(10); } } } } if (!$thenViewHelperEncountered && !$elseViewHelperEncountered && !isset($node->getArguments()['then'])) { $initializationPhpCode .= sprintf('%s[\'__thenClosure\'] = %s;', $argumentsName, $closureName) . chr(10); } return parent::compile($argumentsName, $closureName, $initializationPhpCode, $node, $compiler); }