本文整理汇总了PHP中Cake\View\View::templatePath方法的典型用法代码示例。如果您正苦于以下问题:PHP View::templatePath方法的具体用法?PHP View::templatePath怎么用?PHP View::templatePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\View\View
的用法示例。
在下文中一共展示了View::templatePath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}