本文整理匯總了PHP中CController::resolveViewFile方法的典型用法代碼示例。如果您正苦於以下問題:PHP CController::resolveViewFile方法的具體用法?PHP CController::resolveViewFile怎麽用?PHP CController::resolveViewFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CController
的用法示例。
在下文中一共展示了CController::resolveViewFile方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: renderMessage
public function renderMessage($view, array $data = array())
{
$controller = new \CController('SmsSender');
$viewPath = \Yii::app()->getBasePath() . DIRECTORY_SEPARATOR . 'views';
$viewFile = $controller->resolveViewFile($view, $viewPath, $viewPath);
$body = $controller->renderInternal($viewFile, $data, true);
return $body;
}
示例2: resolveViewFile
/**
* Allows loading view from dressing.views when application, theme and module views are unavailable.
*
* @param string $viewName
* @param string $viewPath
* @param string $basePath
* @param null $moduleViewPath
* @return mixed
*/
public function resolveViewFile($viewName, $viewPath, $basePath, $moduleViewPath = null)
{
$viewFile = parent::resolveViewFile($viewName, $viewPath, $basePath, $moduleViewPath);
if ($viewFile) {
return $viewFile;
}
// if not found in app, try to find in dressing.views
$path = Yii::getPathOfAlias('dressing.views');
$appViewPath = Yii::app()->getViewPath();
$viewPath = $path . str_replace($appViewPath, '', $viewPath);
$basePath = $path . str_replace($appViewPath, '', $basePath);
return parent::resolveViewFile($viewName, $viewPath, $basePath, null);
}
示例3: getLayoutFile
/**
* Finds the layout file for the specified controller's layout.
* @param CController $controller the controller
* @param string $layoutName the layout name
* @return string the layout file path. False if the file does not exist.
*/
public function getLayoutFile($controller, $layoutName)
{
$moduleViewPath = $basePath = $this->getViewPath();
$module = $controller->getModule();
if (empty($layoutName)) {
while ($module !== null) {
if ($module->layout === false) {
return false;
}
if (!empty($module->layout)) {
break;
}
$module = $module->getParentModule();
}
if ($module === null) {
$layoutName = Yii::app()->layout;
} else {
$layoutName = $module->layout;
$moduleViewPath .= '/' . $module->getId();
}
} else {
if ($module !== null) {
$moduleViewPath .= '/' . $module->getId();
}
}
return $controller->resolveViewFile($layoutName, $moduleViewPath . '/layouts', $basePath, $moduleViewPath);
}
示例4: renderBody
/**
* @param string $view
* @param string $layout
* @param array $data
*
* @return string
*/
public function renderBody($view, $layout = '//layouts/main', array $data = array())
{
$controller = new CController('SwiftMailerComponent');
$viewPath = Yii::app()->getBasePath() . DIRECTORY_SEPARATOR . 'views';
$viewFile = $controller->resolveViewFile($view, $viewPath, $viewPath);
$layoutFile = $controller->resolveViewFile($layout, $viewPath, $viewPath);
$body = $controller->renderInternal($viewFile, $data, true);
if (null !== $layout) {
$body = $controller->renderInternal($layoutFile, array('content' => $body), true);
}
return $body;
}