renderPhpFile() public method

This method treats the view file as a PHP script and includes the file. It extracts the given parameters and makes them available in the view file. The method captures the output of the included view file and returns it as a string. This method should mainly be called by view renderer or View::renderFile.
public renderPhpFile ( string $_file_, array $_params_ = [] ) : string
$_file_ string the view file.
$_params_ array the parameters (name-value pairs) that will be extracted and made available in the view file.
return string the rendering result
コード例 #1
0
 /**
  * Renders a view file.
  *
  * This method is invoked by [[View]] whenever it tries to render a view.
  * Child classes must implement this method to render the given view file.
  *
  * @param View $view the view object used for rendering the file.
  * @param string $file the view file.
  * @param array $params the parameters to be passed to the view file.
  * @return string the rendering result
  */
 public function render($view, $file, $params)
 {
     $this->encodeParams($params);
     return $view->renderPhpFile($file, $params);
 }
コード例 #2
0
ファイル: ViewRenderer.php プロジェクト: flexibuild/php-safe
 /**
  * Renders a view file.
  *
  * This method is invoked by [[View]] whenever it tries to render a view.
  * Child classes must implement this method to render the given view file.
  *
  * @param \yii\base\View $view the view object used for rendering the file.
  * @param string $file the view file.
  * @param array $params the parameters to be passed to the view file.
  *
  * @return string the rendering result
  */
 public function render($view, $file, $params)
 {
     if (false === ($hash = $this->loadHashFromCache($file))) {
         $compiledFilePath = $this->compileFile($file, false);
     } else {
         $compiledFilePath = $this->getCompiledFilePath($hash);
     }
     return $view->renderPhpFile($compiledFilePath, $params);
 }