diff --git a/framework/base/Controller.php b/framework/base/Controller.php index a855858..64e8b00 100644 --- a/framework/base/Controller.php +++ b/framework/base/Controller.php @@ -10,55 +10,19 @@ namespace yii\base; /** - * Controller is the base class for {@link CController} and {@link CWidget}. + * Controller is the base class for classes containing controller logic. * - * It provides the common functionalities shared by controllers who need to render views. + * Controller implements the action life cycles, which consist of the following steps: * - * Controller also implements the support for the following features: - * + * 1. [[authorize]] + * 2. [[beforeAction]] + * 3. [[beforeRender]] + * 4. [[afterRender]] + * 5. [[afterAction]] * - * To use a widget in a view, use the following in the view: - *
- * $this->widget('path.to.widgetClass',array('property1'=>'value1',...));
- * 
- * or - *
- * $this->beginWidget('path.to.widgetClass',array('property1'=>'value1',...));
- * // ... display other contents here
- * $this->endWidget();
- * 
- * - * To create a clip, use the following: - *
- * $this->beginClip('clipID');
- * // ... display the clip contents
- * $this->endClip();
- * 
- * Then, in a different view or place, the captured clip can be inserted as: - *
- * echo $this->clips['clipID'];
- * 
- * - * Note that $this in the code above refers to current controller so, for example, - * if you need to access clip from a widget where $this refers to widget itself - * you need to do it the following way: - * - *
- * echo $this->getController()->clips['clipID'];
- * 
- * - * To use fragment cache, do as follows, - *
- * if($this->beginCache('cacheID',array('property1'=>'value1',...))
- * {
- *	 // ... display the content to be cached here
- *	$this->endCache();
- * }
- * 
+ * @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. + * @property string $uniqueId the controller ID that is prefixed with the module ID (if any). * * @author Qiang Xue * @since 2.0 @@ -94,7 +58,7 @@ abstract class Controller extends Component implements Initable /** * Initializes the controller. - * This method is called by the application before the controller starts to execute. + * This method is called by the application before the controller starts to execute an action. * You may override this method to perform the needed initialization for the controller. */ public function init() @@ -256,11 +220,9 @@ abstract class Controller extends Component implements Initable /** * Processes the request using another controller action. - * This is like {@link redirect}, but the user browser's URL remains unchanged. - * In most cases, you should call {@link redirect} instead of this method. * @param string $route the route of the new controller action. This can be an action ID, or a complete route - * with module ID (optional in the current module), controller ID and action ID. If the former, the action is assumed - * to be located within the current controller. + * with module ID (optional in the current module), controller ID and action ID. If the former, + * the action is assumed to be located within the current controller. * @param boolean $exit whether to end the application after this call. Defaults to true. */ public function forward($route, $exit = true) diff --git a/framework/base/ErrorHandler.php b/framework/base/ErrorHandler.php index 7bf81e1..0c3689c 100644 --- a/framework/base/ErrorHandler.php +++ b/framework/base/ErrorHandler.php @@ -15,47 +15,6 @@ namespace yii\base; * ErrorHandler displays these errors using appropriate views based on the * nature of the errors and the mode the application runs at. * - * ErrorHandler does the following when the application encounters an error or exception: - * - * - If it is a PHP error, warning or notice, an ErrorException will be thrown which - * if not caught, will be handled in the next few steps - * - If it is an uncaught exception, it will invoke the action defined by [[errorAction]] - * to handle the exception; - * - If [[errorAction]] is not defined, it will - * - * ErrorHandler uses two sets of views: - * - * where <StatusCode> stands for the HTTP error code (e.g. error500.php). - * Localized views are named similarly but located under a subdirectory - * whose name is the language code (e.g. zh_cn/error500.php). - * - * Development views are displayed when the application is in debug mode - * (i.e. YII_DEBUG is defined as true). Detailed error information with source code - * are displayed in these views. Production views are meant to be shown - * to end-users and are used when the application is in production mode. - * For security reasons, they only display the error message without any - * sensitive information. - * - * ErrorHandler looks for the view templates from the following locations in order: - *
    - *
  1. themes/ThemeName/views/system: when a theme is active.
  2. - *
  3. protected/views/system
  4. - *
  5. framework/views
  6. - *
- * If the view is not found in a directory, it will be looked for in the next directory. - * - * The property {@link maxSourceLines} can be changed to specify the number - * of source code lines to be displayed in development views. - * - * ErrorHandler is a core application component that can be accessed via - * {@link CApplication::getErrorHandler()}. - * - * @property array $error The error details. Null if there is no error. - * @property string $versionInfo - * * @author Qiang Xue * @since 2.0 */ @@ -79,8 +38,13 @@ class ErrorHandler extends ApplicationComponent * This property defaults to null, meaning ErrorHandler will handle the error display. */ public $errorAction; - + /** + * @var string the path of the view file for rendering exceptions + */ public $exceptionView = '@yii/views/exception.php'; + /** + * @var string the path of the view file for rendering errors + */ public $errorView = '@yii/views/error.php'; /** * @var \Exception the exception that is being handled currently @@ -96,19 +60,13 @@ class ErrorHandler extends ApplicationComponent /** * Handles PHP execution errors such as warnings, notices. * - * This method is used as a PHP error handler. It requires - * that constant YII_ENABLE_ERROR_HANDLER be defined true. - * - * This method will first raise an `error` event. - * If the error is not handled by any event handler, it will call - * {@link getErrorHandler errorHandler} to process the error. - * - * The application will be terminated by this method. + * This method is used as a PHP error handler. It will simply raise an `ErrorException`. * * @param integer $code the level of the error raised * @param string $message the error message * @param string $file the filename that the error was raised in * @param integer $line the line number the error was raised at + * @throws \ErrorException the error exception */ public function handleError($code, $message, $file, $line) {