Example #1
1
 public function renderFile($viewFile, $params = [], $context = null)
 {
     if ($this->theme == null) {
         $this->setTheme();
     }
     return parent::renderFile($viewFile, $params, $context);
 }
Example #2
0
 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);
 }
Example #3
0
 public function renderForm(View $view, ActiveForm $form)
 {
     return $view->renderFile('@easyii/views/seo.php', ['model' => $this->getSeoText(), 'form' => $form]);
 }
Example #4
0
 /**
  * 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);
 }
Example #5
0
 /**
  * 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);
 }
Example #6
0
 /**
  * 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);
 }
Example #7
0
 /**
  * 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);
 }
Example #8
0
 /**
  * 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);
 }
Example #9
0
 /**
  * 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);
 }
Example #10
0
 /**
  * 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']]);
     }, '');
 }
 /**
  * @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]);
 }