本文整理汇总了PHP中TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface::getViewHelperVariableContainer方法的典型用法代码示例。如果您正苦于以下问题:PHP RenderingContextInterface::getViewHelperVariableContainer方法的具体用法?PHP RenderingContextInterface::getViewHelperVariableContainer怎么用?PHP RenderingContextInterface::getViewHelperVariableContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface
的用法示例。
在下文中一共展示了RenderingContextInterface::getViewHelperVariableContainer方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderStatic
/**
* Default implementation for use in compiled templates
*
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
if (self::$staticReflectionService === NULL) {
$objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
self::$staticReflectionService = $objectManager->get('TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService');
}
$property = $arguments['property'];
$validatorName = isset($arguments['validatorName']) ? $arguments['validatorName'] : NULL;
$object = isset($arguments['object']) ? $arguments['object'] : NULL;
if (NULL === $object) {
$object = self::getFormObject($renderingContext->getViewHelperVariableContainer());
}
$className = get_class($object);
if (FALSE !== strpos($property, '.')) {
$pathSegments = explode('.', $property);
foreach ($pathSegments as $property) {
if (TRUE === ctype_digit($property)) {
continue;
}
$annotations = self::$staticReflectionService->getPropertyTagValues($className, $property, 'var');
$possibleClassName = array_pop($annotations);
if (FALSE !== strpos($possibleClassName, '<')) {
$className = array_pop(explode('<', trim($possibleClassName, '>')));
} elseif (TRUE === class_exists($possibleClassName)) {
$className = $possibleClassName;
}
}
}
$annotations = self::$staticReflectionService->getPropertyTagValues($className, $property, 'validate');
$hasEvaluated = TRUE;
if (0 < count($annotations) && (NULL === $validatorName || TRUE === in_array($validatorName, $annotations))) {
return static::renderStaticThenChild($arguments, $hasEvaluated);
}
return static::renderStaticElseChild($arguments, $hasEvaluated);
}
示例2: renderStatic
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return void
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$viewHelperVariableContainer = $renderingContext->getViewHelperVariableContainer();
$templateVariableContainer = $renderingContext->getTemplateVariableContainer();
$extensionName = static::getExtensionNameFromRenderingContextOrArguments($renderingContext, $arguments);
$formClassName = FluxPackageFactory::getPackageWithFallback($extensionName)->getImplementation(FluxPackage::IMPLEMENTATION_FORM);
$form = call_user_func_array(array($formClassName, 'create'), array());
$container = $form->last();
// configure Form instance
$form->setId($arguments['id']);
$form->setName($arguments['id']);
$form->setLabel($arguments['label']);
$form->setDescription($arguments['description']);
$form->setEnabled($arguments['enabled']);
$form->setCompact($arguments['compact']);
$form->setExtensionName($extensionName);
$form->setLocalLanguageFileRelativePath($arguments['localLanguageFileRelativePath']);
$form->setVariables((array) $arguments['variables']);
$form->setOptions((array) $arguments['options']);
if (FALSE === $form->hasOption(Form::OPTION_ICON)) {
$form->setOption(Form::OPTION_ICON, $arguments['icon']);
}
if (FALSE === $form->hasOption(Form::OPTION_GROUP)) {
$form->setOption(Form::OPTION_GROUP, $arguments['wizardTab']);
}
// rendering child nodes with Form's last sheet as active container
$viewHelperVariableContainer->addOrUpdate(static::SCOPE, static::SCOPE_VARIABLE_FORM, $form);
$viewHelperVariableContainer->addOrUpdate(static::SCOPE, static::SCOPE_VARIABLE_EXTENSIONNAME, $extensionName);
$templateVariableContainer->add(static::SCOPE_VARIABLE_FORM, $form);
static::setContainerInRenderingContext($renderingContext, $container);
$renderChildrenClosure();
$viewHelperVariableContainer->remove(static::SCOPE, static::SCOPE_VARIABLE_EXTENSIONNAME);
$viewHelperVariableContainer->remove(static::SCOPE, static::SCOPE_VARIABLE_CONTAINER);
$templateVariableContainer->remove(static::SCOPE_VARIABLE_CONTAINER);
}
示例3: renderStatic
/**
* @param array $arguments
* @param callable $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
*
* @return mixed|string
* @throws Exception
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$value = $arguments['value'];
$default = $arguments['default'];
$viewHelperVariableContainer = $renderingContext->getViewHelperVariableContainer();
if (!$viewHelperVariableContainer->exists(SwitchViewHelper::class, 'stateStack')) {
throw new Exception('The case View helper can only be used within a switch View helper', 1368112037);
}
if (is_null($value) && $default === false) {
throw new Exception('The case View helper must have either value or default argument', 1382867521);
}
$stateStack = $viewHelperVariableContainer->get(SwitchViewHelper::class, 'stateStack');
$currentState = array_pop($stateStack);
if ($currentState['break'] === true) {
return '';
}
// non-type-safe comparison by intention
if ($default === true || $currentState['expression'] == $value) {
$currentState['break'] = true;
$stateStack[] = $currentState;
$viewHelperVariableContainer->addOrUpdate(SwitchViewHelper::class, 'stateStack', $stateStack);
return $renderChildrenClosure();
}
return '';
}
示例4: viewHelperVariableContainerCanBeReadCorrectly
/**
* @test
*/
public function viewHelperVariableContainerCanBeReadCorrectly()
{
$viewHelperVariableContainer = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer');
$this->renderingContext->_set('viewHelperVariableContainer', $viewHelperVariableContainer);
$this->assertSame($viewHelperVariableContainer, $this->renderingContext->getViewHelperVariableContainer());
}
示例5: determineBooleanOf
/**
* @param RenderingContextInterface $context
* @param mixed $var
* @return boolean
*/
protected function determineBooleanOf($context, $var)
{
if (TRUE === $context->getViewHelperVariableContainer()->exists('FluidTYPO3\\Vhs\\ViewHelpers\\SwitchViewHelper', $var)) {
return $context->getViewHelperVariableContainer()->get('FluidTYPO3\\Vhs\\ViewHelpers\\SwitchViewHelper', $var);
}
return FALSE;
}
示例6: setRenderingContext
/**
* @param \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
* @return void
*/
public function setRenderingContext(\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
{
$this->renderingContext = $renderingContext;
$this->templateVariableContainer = $renderingContext->getTemplateVariableContainer();
if ($renderingContext->getControllerContext() !== null) {
$this->controllerContext = $renderingContext->getControllerContext();
}
$this->viewHelperVariableContainer = $renderingContext->getViewHelperVariableContainer();
}
示例7: setRenderingContext
/**
* Injects a fresh rendering context
*
* @param \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
* @return void
*/
public function setRenderingContext(\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
{
$this->baseRenderingContext = $renderingContext;
$this->baseRenderingContext->getViewHelperVariableContainer()->setView($this);
$this->controllerContext = $renderingContext->getControllerContext();
}
示例8: setContainerInRenderingContext
/**
* @param RenderingContextInterface $renderingContext
* @param FormInterface $container
* @throws InvalidVariableException
* @return void
*/
protected static function setContainerInRenderingContext(RenderingContextInterface $renderingContext, FormInterface $container)
{
$renderingContext->getViewHelperVariableContainer()->addOrUpdate(static::SCOPE, static::SCOPE_VARIABLE_CONTAINER, $container);
if (TRUE === $renderingContext->getTemplateVariableContainer()->exists(static::SCOPE_VARIABLE_CONTAINER)) {
$renderingContext->getTemplateVariableContainer()->remove(static::SCOPE_VARIABLE_CONTAINER);
}
$renderingContext->getTemplateVariableContainer()->add(static::SCOPE_VARIABLE_CONTAINER, $container);
}
示例9: renderStatic
/**
* Default implementation for CompilableInterface. See CompilableInterface
* for a detailed description of this method.
*
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
* @see \TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$viewHelperVariableContainer = $renderingContext->getViewHelperVariableContainer();
$stackValue = array('expression' => $arguments['expression'], 'break' => false);
if ($viewHelperVariableContainer->exists(SwitchViewHelper::class, 'stateStack')) {
$stateStack = $viewHelperVariableContainer->get(SwitchViewHelper::class, 'stateStack');
} else {
$stateStack = array();
}
$stateStack[] = $stackValue;
$viewHelperVariableContainer->addOrUpdate(SwitchViewHelper::class, 'stateStack', $stateStack);
$result = $renderChildrenClosure();
$stateStack = $viewHelperVariableContainer->get(SwitchViewHelper::class, 'stateStack');
array_pop($stateStack);
$viewHelperVariableContainer->addOrUpdate(SwitchViewHelper::class, 'stateStack', $stateStack);
return $result;
}