当前位置: 首页>>代码示例>>PHP>>正文


PHP View::cache方法代码示例

本文整理汇总了PHP中Cake\View\View::cache方法的典型用法代码示例。如果您正苦于以下问题:PHP View::cache方法的具体用法?PHP View::cache怎么用?PHP View::cache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\View\View的用法示例。


在下文中一共展示了View::cache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 /**
  * Render the cell.
  *
  * @param string|null $template Custom template name to render. If not provided (null), the last
  * value will be used. This value is automatically set by `CellTrait::cell()`.
  * @return string The rendered cell.
  * @throws \Cake\View\Exception\MissingCellViewException When a MissingTemplateException is raised during rendering.
  */
 public function render($template = null)
 {
     if ($template !== null && strpos($template, '/') === false && strpos($template, '.') === false) {
         $template = Inflector::underscore($template);
     }
     if ($template === null) {
         $template = $this->template;
     }
     $builder = $this->viewBuilder();
     $builder->layout(false);
     $builder->template($template);
     $cache = [];
     if ($this->_cache) {
         $cache = $this->_cacheConfig($template);
     }
     $this->View = $this->createView();
     $render = function () use($template) {
         $className = substr(strrchr(get_class($this), "\\"), 1);
         $name = substr($className, 0, -4);
         $this->View->templatePath('Cell' . DS . $name);
         try {
             return $this->View->render($template);
         } catch (MissingTemplateException $e) {
             throw new MissingCellViewException(['file' => $template, 'name' => $name]);
         }
     };
     if ($cache) {
         return $this->View->cache(function () use($render) {
             echo $render();
         }, $cache);
     }
     return $render();
 }
开发者ID:a53ali,项目名称:CakePhP,代码行数:41,代码来源:Cell.php

示例2: render

 /**
  * Render the cell.
  *
  * @param string|null $template Custom template name to render. If not provided (null), the last
  * value will be used. This value is automatically set by `CellTrait::cell()`.
  * @return string The rendered cell
  * @throws \Cake\View\Exception\MissingCellViewException When a MissingTemplateException is raised during rendering.
  */
 public function render($template = null)
 {
     if ($template !== null && strpos($template, '/') === false) {
         $template = Inflector::underscore($template);
     }
     if ($template === null) {
         $template = $this->template;
     }
     $this->View = null;
     $this->getView();
     $this->View->layout = false;
     $cache = [];
     if ($this->_cache) {
         $cache = $this->_cacheConfig($template);
     }
     $render = function () use($template) {
         $className = explode('\\', get_class($this));
         $className = array_pop($className);
         $name = substr($className, 0, strpos($className, 'Cell'));
         $this->View->subDir = 'Cell' . DS . $name;
         try {
             return $this->View->render($template);
         } catch (MissingTemplateException $e) {
             throw new MissingCellViewException(['file' => $template, 'name' => $name]);
         }
     };
     if ($cache) {
         return $this->View->cache(function () use($render) {
             echo $render();
         }, $cache);
     }
     return $render();
 }
开发者ID:neilan35,项目名称:betterwindow1,代码行数:41,代码来源:Cell.php


注:本文中的Cake\View\View::cache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。