diff --git a/framework/base/Controller.php b/framework/base/Controller.php index 7f232ac..a93414e 100644 --- a/framework/base/Controller.php +++ b/framework/base/Controller.php @@ -16,9 +16,7 @@ namespace yii\base; * * 1. [[authorize]] * 2. [[beforeAction]] - * 3. [[beforeRender]] - * 4. [[afterRender]] - * 5. [[afterAction]] + * 3. [[afterAction]] * * @property array $actionParams the request parameters (name-value pairs) to be used for action parameter binding * @property string $route the route (module ID, controller ID and action ID) of the current request. @@ -283,40 +281,9 @@ class Controller extends Component implements Initable $this->trigger(__METHOD__, new ActionEvent($action)); } - /** - * This method is invoked right before an action renders its result using [[render()]]. - * @param string $view the view to be rendered - * @return boolean whether the action should continue to render. - */ - public function beforeRender($view) - { - $event = new RenderEvent($view); - $this->trigger(__METHOD__, $event); - return $event->isValid; - } - - /** - * This method is invoked right after an action renders its result using [[render()]]. - * @param string $view the view just rendered - * @param string $content the content to be displayed - * @return string the content to be displayed. This may be the same as the input content or the one - * modified by event handlers. - */ - public function afterRender($view, $content) - { - $event = new RenderEvent($view, $content); - $this->trigger(__METHOD__, $event); - return $event->content; - } - public function render($view, $params = array()) { - if ($this->beforeRender($view)) { - $content = $this->createView()->render($view, $params); - $content = $this->afterRender($view, $content); - return $content; - } - return ''; + return $this->createView()->render($view, $params); } public function renderText($text) diff --git a/framework/base/RenderEvent.php b/framework/base/RenderEvent.php deleted file mode 100644 index 7c1c817..0000000 --- a/framework/base/RenderEvent.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @since 2.0 - */ -class RenderEvent extends Event -{ - /** - * @var string the view currently being rendered - */ - public $view; - /** - * @var string the content to be displayed - */ - public $content; - /** - * @var boolean whether the action is in valid state and its life cycle should proceed. - */ - public $isValid = true; - - /** - * Constructor. - * @param string $view the view currently being rendered - */ - public function __construct($view) - { - $this->view = $view; - } -} diff --git a/framework/caching/DirectoryDependency.php b/framework/caching/DirectoryDependency.php deleted file mode 100644 index f977bad..0000000 --- a/framework/caching/DirectoryDependency.php +++ /dev/null @@ -1,136 +0,0 @@ - - * @since 2.0 - */ -class DirectoryDependency extends Dependency -{ - /** - * @var string the directory whose change is used to determine if the dependency has been changed. - * If any of the files under the directory is changed, the dependency is considered as changed. - */ - public $directory; - /** - * @var integer the depth of the subdirectories to be recursively checked. - * If the value is less than 0, it means unlimited depth. - * If the value is 0, it means checking the files directly under the specified directory. - */ - public $recursiveLevel = -1; - /** - * @var string the regular expression matching valid file/directory names. - * Only the matching files or directories will be checked for changes. - * Defaults to null, meaning all files/directories will qualify. - */ - public $namePattern; - - /** - * Constructor. - * @param string $directory the directory to be checked - */ - public function __construct($directory = null) - { - $this->directory = $directory; - } - - /** - * Generates the data needed to determine if dependency has been changed. - * This method returns the modification timestamps for files under the directory. - * @return mixed the data needed to determine if dependency has been changed. - */ - protected function generateDependencyData() - { - if ($this->directory !== null) { - return $this->generateTimestamps($this->directory); - } else { - throw new CException(Yii::t('yii', 'DirectoryDependency.directory cannot be empty.')); - } - } - - /** - * Determines the last modification time for files under the directory. - * This method may go recursively into subdirectories if {@link recursiveLevel} is not 0. - * @param string $directory the directory name - * @param integer $level level of the recursion - * @return array list of file modification time indexed by the file path - */ - protected function generateTimestamps($directory, $level = 0) - { - if (($dir = @opendir($directory)) === false) { - throw new CException(Yii::t('yii', '"{path}" is not a valid directory.', - array('{path}' => $directory))); - } - $timestamps = array(); - while (($file = readdir($dir)) !== false) { - $path = $directory . DIRECTORY_SEPARATOR . $file; - if ($file === '.' || $file === '..') { - continue; - } - if ($this->namePattern !== null && !preg_match($this->namePattern, $file)) { - continue; - } - if (is_file($path)) { - if ($this->validateFile($path)) { - $timestamps[$path] = filemtime($path); - } - } else { - if (($this->recursiveLevel < 0 || $level < $this->recursiveLevel) && $this->validateDirectory($path)) { - $timestamps = array_merge($timestamps, $this->generateTimestamps($path, $level + 1)); - } - } - } - closedir($dir); - return $timestamps; - } - - /** - * Checks to see if the file should be checked for dependency. - * This method is invoked when dependency of the whole directory is being checked. - * By default, it always returns true, meaning the file should be checked. - * You may override this method to check only certain files. - * @param string $fileName the name of the file that may be checked for dependency. - * @return boolean whether this file should be checked. - */ - protected function validateFile($fileName) - { - return true; - } - - /** - * Checks to see if the specified subdirectory should be checked for dependency. - * This method is invoked when dependency of the whole directory is being checked. - * By default, it always returns true, meaning the subdirectory should be checked. - * You may override this method to check only certain subdirectories. - * @param string $directory the name of the subdirectory that may be checked for dependency. - * @return boolean whether this subdirectory should be checked. - */ - protected function validateDirectory($directory) - { - return true; - } -}