Yii2 Bootstrap 3
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.4 KiB

12 years ago
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
12 years ago
* @license http://www.yiiframework.com/license/
*/
namespace yii\widgets;
use Yii;
use yii\base\InvalidConfigException;
use yii\base\Widget;
use yii\base\View;
12 years ago
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
12 years ago
*/
class ContentDecorator extends Widget
12 years ago
{
/**
* @var View the view object for rendering [[viewName]]. If not set, the view registered with the application
* will be used.
12 years ago
*/
public $view;
/**
* @var string the name of the view that will be used to decorate the content enclosed by this widget.
* Please refer to [[View::findViewFile()]] on how to set this property.
12 years ago
*/
public $viewName;
/**
* @var array the parameters (name=>value) to be extracted and made available in the decorative view.
*/
public $params = array();
12 years ago
/**
* Starts recording a clip.
12 years ago
*/
public function init()
12 years ago
{
if ($this->viewName === null) {
throw new InvalidConfigException('ContentDecorator::viewName must be set.');
}
ob_start();
ob_implicit_flush(false);
12 years ago
}
/**
* Ends recording a clip.
* This method stops output buffering and saves the rendering result as a named clip in the controller.
12 years ago
*/
public function run()
12 years ago
{
$params = $this->params;
$params['content'] = ob_get_clean();
$view = $this->view !== null ? $this->view : Yii::$app->getView();
echo $view->render($this->viewName, $params);
12 years ago
}
}