Renders an argument.

@param BlockLayout $layout   The layout.
@param Argument    $argument The argument to render.
962497
protected function renderArgument(BlockLayout $layout, Argument $argument)
    {
        $description = $argument->getDescription();
        $name = '<c1><'.$argument->getName().'></c1>';
        $defaultValue = $argument->getDefaultValue();

        if (null !== $defaultValue && (!is_array($defaultValue) || count($defaultValue))) {
            $description .= sprintf(' <b>(default: %s)</b>', $this->formatValue($defaultValue));
        }

        $layout->add(new LabeledParagraph($name, $description));
    }
51152
public function render(string $layout = null, array $context = [])
    {
        if (null === $layout) {
            $layout = 'default';
        }
        $type = $this->getFlexType();

        $grav = Grav::instance();

        /** @var Debugger $debugger */
        $debugger = $grav['debugger'];
        $debugger->startTimer('flex-collection-' . ($debugKey =  uniqid($type, false)), 'Render Collection ' . $type . ' (' . $layout . ')');

        $cache = $key = null;
        foreach ($context as $value) {
            if (!\is_scalar($value)) {
                $key = false;
            }
        }

        if ($key !== false) {
            $key = md5($this->getCacheKey() . '.' . $layout . json_encode($context));
            $cache = $this->getCache('render');
        }

        try {
            $data = $cache ? $cache->get($key) : null;

            $block = $data ? HtmlBlock::fromArray($data) : null;
        } catch (InvalidArgumentException $e) {
            $debugger->addException($e);
            $block = null;
        } catch (\InvalidArgumentException $e) {
            $debugger->addException($e);
            $block = null;
        }

        $checksum = $this->getCacheChecksum();
        if ($block && $checksum !== $block->getChecksum()) {
            $block = null;
        }

        if (!$block) {
            $block = HtmlBlock::create($key);
            $block->setChecksum($checksum);
            if ($key === false) {
                $block->disableCache();
            }

            $grav->fireEvent('onFlexCollectionRender', new Event([
                'collection' => $this,
                'layout' => &$layout,
                'context' => &$context
            ]));

            $output = $this->getTemplate($layout)->render(
                ['grav' => $grav, 'config' => $grav['config'], 'block' => $block, 'collection' => $this, 'layout' => $layout] + $context
            );

            if ($debugger->enabled()) {
                $output = "\n<!–– START {$type} collection ––>\n{$output}\n<!–– END {$type} collection ––>\n";
            }

            $block->setContent($output);

            try {
                $cache && $block->isCached() && $cache->set($key, $block->toArray());
            } catch (InvalidArgumentException $e) {
                $debugger->addException($e);
            }
        }

        $debugger->stopTimer('flex-collection-' . $debugKey);

        return $block;
    }
140960
public function setEventLayout($flag, $value, array $layout)
    {
        $value = (string) $value;
        $this->eventLayout[$flag][$value] = $layout;
    }
108325
protected function renderCommands(BlockLayout $layout, CommandCollection $commands)
    {
        $layout->add(new Paragraph('<b>AVAILABLE COMMANDS</b>'));
        $layout->beginBlock();

        $commands = $commands->toArray();
        ksort($commands);

        foreach ($commands as $command) {
            $this->renderCommand($layout, $command);
        }

        $layout->endBlock();
        $layout->add(new EmptyLine());
    }
1100387
private function addTranslations(Layout $layout, array $layoutData): void
    {
        $translationLocales = $this->extractTranslationLocales($layoutData);

        foreach ($translationLocales as $locale) {
            $this->layoutService->addTranslation($layout, $locale, $layoutData['main_locale']);
        }
    }
1109984
public function setLayout($layout = null)
    {
        if (null !== $layout && !is_string($layout) && !($layout instanceof ViewModel)) {
            throw new InvalidArgumentException(
                'Invalid value supplied for setLayout.'.
                'Expected null, string, or Zend\View\Model\ViewModel.'
            );
        }

        if (null === $layout && empty($this->config['message']['layout'])) {
            return;
        }

        if (null === $layout) {
            $layout = (string) $this->config['message']['layout'];

            unset($this->config['message']['layout']);
        }

        if (is_string($layout)) {

            $template   = $layout;
            $layout     = new ViewModel;

            $layout->setTemplate($template);
        }

        $this->layout = $layout;
    }
1330334
public function renderResponse(BlockInterface $block, array $parameters = array(), Response $response = null)
    {
        $view = $this->getView($block);

        if ($response) {
            $this->setResponseHeaders($block, $response);
        }

        return $this->blockRenderer->render($view, $parameters, $response);
    }
520673
public function renderInitCmsBlock($template, LayoutBlockInterface $layoutBlock, $params = [])
    {
        if (!$serializedContent = $layoutBlock->getSnapshotContent()) {
            // Draft View
            $contentItem = $layoutBlock->getContent();
        } else {
            // Live View
            $contentItem = $this->serializer->deserialize(
                $serializedContent,
                $layoutBlock->getClassType(),
                'json'
            );
        }

        if (!is_object($contentItem)) {
            $this->layoutBlockAdmin->delete($layoutBlock);

            return '---';
        }

        $options = $contentItem->getTemplateOptions($params);

        $options = array_merge($options, $params);

        return $this->templating->render($template, $options);
    }
1061346
protected function renderLayoutView(array $templateArguments)
    {
        $fieldName = $this->arguments['name'];
        $formObject = $this->formService->getFormObject();
        $formConfiguration = $formObject->getConfiguration();
        $viewConfiguration = $formConfiguration->getRootConfiguration()->getView();
        $layout = $this->getLayout($viewConfiguration);

        $templateArguments['layout'] = $layout->getLayout();
        $templateArguments['formName'] = $formObject->getName();
        $templateArguments['fieldName'] = $fieldName;
        $templateArguments['fieldId'] = ($templateArguments['fieldId']) ?: StringService::get()->sanitizeString('formz-' . $formObject->getName() . '-' . $fieldName);

        $currentView = $this->viewHelperVariableContainer->getView();
        $currentVariables = [];

        $view = $this->fieldService->getView($layout);

        /*
         * Warning: we need to store the layouts/partials paths before
         * manipulating the rendering context!
         */
        $layoutPaths = $this->getPaths('layout');
        $partialPaths = $this->getPaths('partial');

        if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '8.0.0', '<')) {
            $view->setRenderingContext($this->renderingContext);
        } else {
            $currentVariables = $this->renderingContext->getVariableProvider()->getAll();

            /*
             * Updating the view dependencies: the variable container as well as
             * the controller context must be injected in the view.
             */
            $this->viewHelperVariableContainer->setView($view);

            $view->getRenderingContext()->setViewHelperVariableContainer($this->viewHelperVariableContainer);

            $view->setControllerContext($this->controllerContext);

            /*
             * Adding current variables to the field view variables.
             */
            $tmpVariables = $currentVariables;
            ArrayUtility::mergeRecursiveWithOverrule($tmpVariables, $templateArguments);
            $templateArguments = $tmpVariables;
        }

        $view->setLayoutRootPaths($layoutPaths);
        $view->setPartialRootPaths($partialPaths);
        $view->assignMultiple($templateArguments);

        $result = $view->render();

        if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '8.0.0', '>=')) {
            /*
             * Because the view can be used several times in nested fields, we
             * need to restore the variables after the view was rendered.
             */
            $viewVariableProvider = $view->getRenderingContext()->getVariableProvider();

            foreach ($viewVariableProvider->getAllIdentifiers() as $identifier) {
                $viewVariableProvider->remove($identifier);
            }

            foreach ($currentVariables as $key => $value) {
                $viewVariableProvider->add($key, $value);
            }

            /*
             * Resetting the view of the variable container with the original
             * view.
             */
            $this->viewHelperVariableContainer->setView($currentView);
        }

        return $result;
    }
996069
public function renderLayout($content, $layout = null)
    {
        $html = parent::renderLayout($content, $layout);

        return $this->shortcodes($html);
    }
930005
public function addArgument(Argument $argument) {
        if (isset($this->arguments[$argument->getName()])) {
            throw new \LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName()));
        }

        if ($this->hasAnArrayArgument) {
            throw new \LogicException('Cannot add an argument after an array argument.');
        }

        if ($argument->isRequired() && $this->hasOptional) {
            throw new \LogicException('Cannot add a required argument after an optional one.');
        }

        if ($argument->isArray()) {
            $this->hasAnArrayArgument = true;
        }

        if ($argument->isRequired()) {
            ++$this->requiredCount;
        }
        else {
            $this->hasOptional = true;
        }

        $this->arguments[$argument->getName()] = $argument;
    }
656230
public function renderCall($method, array $arguments = [], $semicolon = false, $newLine = false)
    {
        return $this->renderCode(
            $method.$this->renderArguments($arguments),
            $semicolon,
            $newLine
        );
    }
1171107
public function initializeLayout($page, \LayoutModel $layout)
	{
		static::$pageLayout = $layout;

		if(!static::isEnabled())
		{
			return;
		}

		// reset default framework
		static::$pageLayout->framework = null;

		$templates = $GLOBALS['BOOTSTRAP']['templates']['dynamicLoad'];

		// only load these templates if layout uses it because default templates are changed
		foreach ($templates as $path => $templates)
		{
			foreach ($templates as $template)
			{
				\TemplateLoader::addFile($template, $path);
			}
		}
	}
566663
protected function renderOptions(BlockLayout $layout, array $options)
    {
        $layout->add(new Paragraph('<b>OPTIONS</b>'));
        $layout->beginBlock();

        foreach ($options as $option) {
            $this->renderOption($layout, $option);
        }

        $layout->endBlock();
        $layout->add(new EmptyLine());
    }
755935
public function setLayout($layout)
    {
        if (strpos($layout, ':'))
        {
            $layout = explode(':', $layout);
            $layout = str_replace('.html', '', array_pop($layout));
        }

        return parent::setLayout($layout);
    }
416868
protected function renderContent(Content $content, $viewType, $layout = false, array $params = array())
    {
        return $this->viewManager->renderContent($content, $viewType, $params + array('noLayout' => !$layout));
    }
1142140
public function updateLayout(Layout $layout): void
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->update('ngbm_layout')
            ->set('type', ':type')
            ->set('name', ':name')
            ->set('description', ':description')
            ->set('created', ':created')
            ->set('modified', ':modified')
            ->set('shared', ':shared')
            ->set('main_locale', ':main_locale')
            ->where(
                $query->expr()->eq('id', ':id')
            )
            ->setParameter('id', $layout->id, Type::INTEGER)
            ->setParameter('type', $layout->type, Type::STRING)
            ->setParameter('name', $layout->name, Type::STRING)
            ->setParameter('description', $layout->description, Type::STRING)
            ->setParameter('created', $layout->created, Type::INTEGER)
            ->setParameter('modified', $layout->modified, Type::INTEGER)
            ->setParameter('shared', $layout->shared, Type::BOOLEAN)
            ->setParameter('main_locale', $layout->mainLocale, Type::STRING);

        $this->applyStatusCondition($query, $layout->status);

        $query->execute();
    }