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.

53 lines
1.2 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\base\InvalidConfigException;
use yii\base\Widget;
12 years ago
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
12 years ago
*/
class ContentDecorator extends Widget
12 years ago
{
/**
12 years ago
* @var string the view file that will be used to decorate the content enclosed by this widget.
* This can be specified as either the view file path or path alias.
12 years ago
*/
12 years ago
public $viewFile;
/**
12 years ago
* @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
{
12 years ago
if ($this->viewFile === null) {
throw new InvalidConfigException('ContentDecorator::viewFile 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();
12 years ago
// render under the existing context
echo $this->view->renderFile($this->viewFile, $params);
12 years ago
}
}