本文整理汇总了PHP中Symfony\Component\Form\FormView::all方法的典型用法代码示例。如果您正苦于以下问题:PHP FormView::all方法的具体用法?PHP FormView::all怎么用?PHP FormView::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormView
的用法示例。
在下文中一共展示了FormView::all方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderSection
/**
* Renders a template.
*
* 1. This function first looks for a block named "_<view id>_<section>",
* 2. if such a block is not found the function will look for a block named
* "<type name>_<section>",
* 3. the type name is recursively replaced by the parent type name until a
* corresponding block is found
*
* @param FormView $view The form view
* @param string $section The section to render (i.e. 'row', 'widget', 'label', ...)
* @param array $variables Additional variables
*
* @return string The html markup
*
* @throws FormException if no template block exists to render the given section of the view
*/
protected function renderSection(FormView $view, $section, array $variables = array())
{
$mainTemplate = in_array($section, array('row', 'widget'));
if ($mainTemplate && $view->isRendered()) {
return '';
}
$template = null;
$custom = '_' . $view->get('id');
$rendering = $custom . $section;
if (isset($this->varStack[$rendering])) {
$typeIndex = $this->varStack[$rendering]['typeIndex'] - 1;
$types = $this->varStack[$rendering]['types'];
$variables = array_replace_recursive($this->varStack[$rendering]['variables'], $variables);
} else {
$types = $view->get('types');
$types[] = $custom;
$typeIndex = count($types) - 1;
$variables = array_replace_recursive($view->all(), $variables);
$this->varStack[$rendering]['types'] = $types;
}
$this->varStack[$rendering]['variables'] = $variables;
do {
$types[$typeIndex] .= '_' . $section;
$template = $this->lookupTemplate($view, $types[$typeIndex]);
if ($template) {
$this->varStack[$rendering]['typeIndex'] = $typeIndex;
$this->context[] = array('variables' => $variables, 'view' => $view);
$html = $this->engine->render($template, $variables);
array_pop($this->context);
unset($this->varStack[$rendering]);
if ($mainTemplate) {
$view->setRendered();
}
return $html;
}
} while (--$typeIndex >= 0);
throw new FormException(sprintf('Unable to render the form as none of the following blocks exist: "%s".', implode('", "', array_reverse($types))));
}
示例2: renderSection
protected function renderSection(FormView $view, $section, array $variables = array())
{
$template = null;
$blocks = $view->get('types');
foreach ($blocks as &$block) {
$block = $block.'_'.$section;
$template = $this->lookupTemplate($block);
if ($template) {
break;
}
}
if (!$template) {
throw new FormException(sprintf('Unable to render form as none of the following blocks exist: "%s".', implode('", "', $blocks)));
}
if ('widget' === $section || 'row' === $section) {
$view->setRendered();
}
return $this->render($template, array_merge($view->all(), $variables));
}
示例3: render
public function render(FormView $view, $template, array $variables = array())
{
$this->varStack[$view] = array_replace(
$view->all(),
isset($this->varStack[$view]) ? $this->varStack[$view] : array(),
$variables
);
$this->viewStack[] = $view;
$html = $this->engine->render($template, $this->varStack[$view]);
array_pop($this->viewStack);
unset($this->varStack[$view]);
return $html;
}
示例4: render
protected function render(FormView $view, $section, array $variables = array())
{
$mainTemplate = in_array($section, array('widget', 'row'));
if ($mainTemplate && $view->isRendered()) {
return '';
}
$id = '_' . $view->get('proto_id', $view->get('id'));
$template = $id . $section;
$renderer = $this->getRenderer();
if (isset($this->varStack[$template])) {
$typeIndex = $this->varStack[$template]['typeIndex'] - 1;
$types = $this->varStack[$template]['types'];
$this->varStack[$template]['variables'] = array_replace_recursive($this->varStack[$template]['variables'], $variables);
} else {
$types = $view->get('types');
$types[] = $id;
$typeIndex = count($types) - 1;
$this->varStack[$template] = array('variables' => array_replace_recursive($view->all(), $variables), 'types' => $types);
}
do {
$types[$typeIndex] .= '_' . $section;
if (isset($renderer[$types[$typeIndex]])) {
$this->varStack[$template]['typeIndex'] = $typeIndex;
$html = $renderer[$types[$typeIndex]]->render($view, $this->varStack[$template]['variables'], $this);
if ($mainTemplate) {
$view->setRendered();
}
unset($this->varStack[$template]);
return $html;
}
} while (--$typeIndex >= 0);
throw new FormException(sprintf('Unable to render the form as none of the following renderer exist: "%s".', implode('", "', array_reverse($types))));
}