本文整理汇总了PHP中yii\web\View::renderFile方法的典型用法代码示例。如果您正苦于以下问题:PHP View::renderFile方法的具体用法?PHP View::renderFile怎么用?PHP View::renderFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\web\View
的用法示例。
在下文中一共展示了View::renderFile方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderFile
public function renderFile($viewFile, $params = [], $context = null)
{
if ($this->theme == null) {
$this->setTheme();
}
return parent::renderFile($viewFile, $params, $context);
}
示例2: renderFile
public function renderFile($viewFile, $params = [], $context = null)
{
$controller = Yii::$app->controller;
if ($controller && $controller->hasMethod('getLeftMenuItems')) {
$params['leftMenuItems'] = $controller->getLeftMenuItems();
}
return parent::renderFile($viewFile, $params, $context);
}
示例3: renderForm
public function renderForm(View $view, ActiveForm $form)
{
return $view->renderFile('@easyii/views/seo.php', ['model' => $this->getSeoText(), 'form' => $form]);
}
示例4: renderFile
/**
* Add in some controller parameters that we want to make available to all
* views without needing to pass them explicitly
*
* (non-PHPdoc)
* @see \yii\base\View::renderFile($viewFile, $params, $context)
*/
public function renderFile($viewFile, $params = [], $context = null)
{
if (!$params) {
$params = [];
}
if (method_exists(\Yii::$app->controller, 'getParameters')) {
if (\Yii::$app->controller->getParameters()) {
$params = array_merge(\Yii::$app->controller->getParameters(), $params);
}
}
return parent::renderFile($viewFile, $params, $context);
}
示例5: render
/**
* Generates code using the specified code template and parameters.
* Note that the code template will be used as a PHP file.
* @param string $template the code template file. This must be specified as a file path
* relative to [[templatePath]].
* @param array $params list of parameters to be passed to the template file.
* @return string the generated code
*/
public function render($template, $params = [])
{
$view = new View();
$params['generator'] = $this;
return $view->renderFile($this->getTemplatePath() . '/' . $template, $params, $this);
}
示例6: getConfigFileContent
/**
* Returns the content of the config file that will be generated in the
* config directory.
*
* @return string the config file content
*/
private function getConfigFileContent()
{
$view = new View();
return $view->renderFile(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'config.php', ['password' => $this->getRandomPassword(), 'iv' => $this->getRandomPassword(\nickcv\encrypter\components\Encrypter::IV_LENGTH)], $this);
}
示例7: render
/**
* Generates code using the specified code template and parameters.
* Note that the code template will be used as a PHP file.
* @param string $template the code template file. This must be specified as a file path
* relative to [[templatePath]].
* @param array $params list of parameters to be passed to the template file.
* @return string the generated code
*/
public function render($template, $params = [])
{
$view = new View();
$params['generator'] = $this;
return $view->renderFile(dirname((new \ReflectionClass($this))->getFileName()) . '/../resources/templates/' . $template, $params, $this);
}
示例8: render
/**
* Looks in parent dir too.
*/
public function render($template, $params = [])
{
$view = new View();
$params['generator'] = $this;
$path = $this->getTemplatePath() . '/' . $template;
if (!file_exists($path)) {
/// XXX quick solution, better redo
$class = (new \ReflectionClass($this))->getParentClass();
$dir = dirname($class->getFileName()) . '/default';
$path = $dir . '/' . $template;
}
return $view->renderFile($path, $params, $this);
}
示例9: renderFile
/**
* Generates code using the specified code template and parameters.
* Note that the code template will be used as a PHP file.
* @param string $template the code template file. This must be specified as a file path
* relative to [[templatePath]].
* @param array $params list of parameters to be passed to the template file.
* @return string the generated code
*/
public function renderFile($file, $params = [])
{
$view = new View();
$params['generator'] = $this;
return $view->renderFile($file, $params, $this);
}
示例10: bcRenderCartPreview
/**
* Backward compatibility
* @param Order $order
* @param View $view
* @param array $products
* @return string
*/
private static function bcRenderCartPreview(Order $order, View $view, $products = [])
{
return array_reduce($products, function ($result, $item) use($order, $view) {
return $result .= $view->renderFile(ShopModule::getInstance()->getViewPath() . '/cart/item-modal-preview.php', ['order' => $order, 'orderItem' => $item['orderItem'], 'product' => $item['model']]);
}, '');
}
示例11: runRelations
/**
* @inheritdoc
*/
public function runRelations()
{
$view = new View();
foreach ($this->relations as $index => &$relation) {
$this->findRelationName($this->tableName, $relation);
}
return $view->renderFile($this->migrationTemplate, ['tableName' => $this->addTablePrefix($this->tableName), 'tableNameRaw' => $this->tableNameRaw, 'fields' => $this->columns, 'classname' => $this->getMigrationName($this->prefix . $this->tableName), 'foreignKey' => $this->relations ?: [], 'db' => $this->db, 'fieldNames' => ArrayHelper::map($this->fields, 'name', 'name'), 'primaryKeys' => $this->primaryKeys]);
}