本文整理匯總了PHP中Phalcon\Mvc\View::getDI方法的典型用法代碼示例。如果您正苦於以下問題:PHP View::getDI方法的具體用法?PHP View::getDI怎麽用?PHP View::getDI使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Phalcon\Mvc\View
的用法示例。
在下文中一共展示了View::getDI方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getServiceViewPath
/**
* {@inheritdoc}
* @internal
*/
private function getServiceViewPath()
{
if (!$this->view->getDI()->has('modules')) {
throw new ModulesNotSetException();
}
$modules = $this->view->getDI()->get('modules');
if (!isset($modules[$this->moduleName]['path'])) {
throw new ModuleNotFoundException();
}
$modulePath = str_replace(DIRECTORY_SEPARATOR . 'Module.php', '', $modules[$this->moduleName]['path']);
$viewsDir = $modulePath . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR;
return $viewsDir;
}
示例2: beforeRender
/**
* Before render view
*
* @param PEvent $event
* @param PView $view
*/
public function beforeRender(PEvent $event, PView $view)
{
$defaultTemplate = $view->getDI()->get("config")->frontendTemplate->defaultTemplate;
$viewDir = ROOT_PATH . "/app/templates/frontend/" . $defaultTemplate . "/modules/" . $this->moduleBaseName . "/";
$pathView = $viewDir . $view->getControllerName() . "/" . $view->getActionName();
$view->setVar("_templateDir", ROOT_PATH . "/app/templates/frontend/" . $defaultTemplate);
if (realpath($pathView . ".volt")) {
$view->setViewsDir($viewDir);
}
}
示例3: beforeRender
/**
* Before render
*
* @param PEvent $event
* @param PView $view
* @return PView
*/
public function beforeRender($event, $view)
{
$view->setVar('_limit', $view->getDI()->get('config')->pagination->limit);
if (isset($view->_sortColumn) && isset($view->_filter)) {
$filter = array_column($view->_sortColumn, 'filter');
if (!empty($filter)) {
$filterForm = new ZFormFilter($filter, $view->_filter);
$view->setVar('_filterColumn', $filterForm->getForm());
}
}
$view->setVar('_toolbarHelpers', ZToolbarHelper::getInstance($this->moduleBaseName, $view->getControllerName()));
}