public function run()
{
$controller = $this->getController();
if ($this->layout !== null) {
$layout = $controller->layout;
$controller->layout = is_callable($this->layout) ? call_user_func($this->layout) : $this->layout;
}
$this->onBeforeRender($event = new CEvent($this));
if (!$event->handled) {
$dataProviderClass = $this->dataProviderClass;
$dataProvider = new $dataProviderClass($this->modelClass, CMap::mergeArray(['criteria' => $this->criteria], $this->dataProviderConfig));
$controller->render(is_callable($this->view) ? call_user_func($this->view) : $this->view, ['dataProvider' => $dataProvider]);
$this->onAfterRender(new CEvent($this));
}
if ($this->layout !== null) {
$controller->layout = $layout;
}
}