本文整理汇总了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;
}