本文整理匯總了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();
}