/** * {@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(); }
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); }); }
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); } } }