本文整理汇总了PHP中Twig_Template::displayBlock方法的典型用法代码示例。如果您正苦于以下问题:PHP Twig_Template::displayBlock方法的具体用法?PHP Twig_Template::displayBlock怎么用?PHP Twig_Template::displayBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Twig_Template
的用法示例。
在下文中一共展示了Twig_Template::displayBlock方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderBlock
/**
* {@inheritdoc}
*/
public function renderBlock(FormView $view, $resource, $blockName, array $variables = array())
{
$cacheKey = $view->vars[self::CACHE_KEY_VAR];
$context = $this->environment->mergeGlobals($variables);
ob_start();
// By contract,This method can only be called after getting the resource
// (which is passed to the method). Getting a resource for the first time
// (with an empty cache) is guaranteed to invoke loadResourcesFromTheme(),
// where the property $template is initialized.
// We do not call renderBlock here to avoid too many nested level calls
// (XDebug limits the level to 100 by default)
$this->template->displayBlock($blockName, $context, $this->resources[$cacheKey]);
return ob_get_clean();
}
示例2: set_lazy_block
public function set_lazy_block(array &$context, \Twig_Template $tpl, $name, $key)
{
if (empty($key) || !is_string($key)) {
throw new \Exception(sprintf("key(%s) must be string", json_encode($key)));
}
\Dev::shareCacheValue($key, function ($app) use(&$context, &$tpl, $name) {
$tpl->displayBlock($name, $context);
});
}
示例3: displayBlock
public function displayBlock($name, array $context, array $blocks = array(), $useBlocks = true)
{
/*
if (($this->getTemplateName() == '@Base/layout.html' || $this->getTemplateName() == '@Base/layout.json')
&& $name == 'content') {
echo \Sentinel::panel();
}
*/
if ($name == 'left') {
$this->_loadBlocks(1);
} else {
if ($name == 'right') {
$this->_loadBlocks(3);
// \Phpfox::getBlock('ad.display', array('block_id' => 3));
echo '<div id="end_right"></div>';
} else {
if ($name == 'content') {
$this->_loadBlocks(2);
} else {
if ($name == 'top') {
$this->_loadBlocks(11);
}
}
}
}
$baseBlocks = ['h1', 'breadcrumb', 'top', 'content'];
if (in_array($name, $baseBlocks)) {
echo '<div class="_block_' . $name . '">';
}
parent::displayBlock($name, $context, $blocks, $useBlocks);
if (in_array($name, $baseBlocks)) {
echo '</div>';
}
if ($name == 'content') {
$this->_loadBlocks(4);
} else {
if ($name == 'top') {
$this->_loadBlocks(7);
}
}
}