diff --git a/framework/base/Application.php b/framework/base/Application.php
index 3ce1272..3daf4c4 100644
--- a/framework/base/Application.php
+++ b/framework/base/Application.php
@@ -39,9 +39,9 @@ namespace yii\base;
*
load application configuration;
* set up class autoloader and error handling;
* load static application components;
- * {@link onBeginRequest}: preprocess the user request;
+ * {@link beforeRequest}: preprocess the user request; `beforeRequest` event raised.
* {@link processRequest}: process the user request;
- * {@link onEndRequest}: postprocess the user request;
+ * {@link afterRequest}: postprocess the user request; `afterRequest` event raised.
*
*
* Starting from lifecycle 3, if a PHP error or an uncaught exception occurs,
@@ -154,12 +154,12 @@ abstract class Application extends Module
*/
public function run()
{
- if ($this->hasEventHandlers('onBeginRequest')) {
- $this->onBeginRequest(new CEvent($this));
+ if ($this->hasEventHandlers('beforeRequest')) {
+ $this->beforeRequest(new CEvent($this));
}
$this->processRequest();
- if ($this->hasEventHandlers('onEndRequest')) {
- $this->onEndRequest(new CEvent($this));
+ if ($this->hasEventHandlers('afterRequest')) {
+ $this->afterRequest(new CEvent($this));
}
}
@@ -183,22 +183,22 @@ abstract class Application extends Module
/**
* Raised right BEFORE the application processes the request.
- * @param CEvent $event the event parameter
+ * @param Event $event the event parameter
*/
- public function onBeginRequest($event)
+ public function beforeRequest($event)
{
- $this->raiseEvent('onBeginRequest', $event);
+ $this->trigger('beforeRequest', $event);
}
/**
* Raised right AFTER the application processes the request.
- * @param CEvent $event the event parameter
+ * @param Event $event the event parameter
*/
- public function onEndRequest($event)
+ public function afterRequest($event)
{
if (!$this->_ended) {
$this->_ended = true;
- $this->raiseEvent('onEndRequest', $event);
+ $this->trigger('afterRequest', $event);
}
}
@@ -688,7 +688,7 @@ abstract class Application extends Module
* This method is implemented as a PHP exception handler. It requires
* that constant YII_ENABLE_EXCEPTION_HANDLER be defined true.
*
- * This method will first raise an {@link onException} event.
+ * This method will first raise an `exception` event.
* If the exception is not handled by any event handler, it will call
* {@link getErrorHandler errorHandler} to process the exception.
*
@@ -758,7 +758,7 @@ abstract class Application extends Module
* This method is implemented as a PHP error handler. It requires
* that constant YII_ENABLE_ERROR_HANDLER be defined true.
*
- * This method will first raise an {@link onError} event.
+ * 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.
*
@@ -845,31 +845,31 @@ abstract class Application extends Module
/**
* Raised when an uncaught PHP exception occurs.
*
- * An event handler can set the {@link CExceptionEvent::handled handled}
+ * An event handler can set the {@link ExceptionEvent::handled handled}
* property of the event parameter to be true to indicate no further error
* handling is needed. Otherwise, the {@link getErrorHandler errorHandler}
* application component will continue processing the error.
*
- * @param CExceptionEvent $event event parameter
+ * @param ExceptionEvent $event event parameter
*/
public function onException($event)
{
- $this->raiseEvent('onException', $event);
+ $this->trigger('exception', $event);
}
/**
* Raised when a PHP execution error occurs.
*
- * An event handler can set the {@link CErrorEvent::handled handled}
+ * An event handler can set the {@link ErrorEvent::handled handled}
* property of the event parameter to be true to indicate no further error
* handling is needed. Otherwise, the {@link getErrorHandler errorHandler}
* application component will continue processing the error.
*
- * @param CErrorEvent $event event parameter
+ * @param ErrorEvent $event event parameter
*/
public function onError($event)
{
- $this->raiseEvent('onError', $event);
+ $this->trigger('error', $event);
}
/**
diff --git a/framework/base/Model.php b/framework/base/Model.php
index aa361b1..e0e3d07 100644
--- a/framework/base/Model.php
+++ b/framework/base/Model.php
@@ -24,8 +24,8 @@ use yii\util\Text;
*
* Model also provides a set of events for further customization:
*
- * - [[onBeforeValidate]]: an event raised at the beginning of [[validate()]]
- * - [[onAfterValidate]]: an event raised at the end of [[validate()]]
+ * - `beforeValidate`: raised at the beginning of [[validate()]]
+ * - `afterValidate`: raised at the end of [[validate()]]
*
* You may directly use Model to store model data, or extend it with customization.
* You may also customize Model by attaching [[ModelBehavior|model behaviors]].
@@ -198,7 +198,7 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
/**
* This method is invoked before validation starts.
- * The default implementation raises the [[onBeforeValidate]] event.
+ * The default implementation raises the `beforeValidate` event.
* You may override this method to do preliminary checks before validation.
* Make sure the parent implementation is invoked so that the event can be raised.
* @return boolean whether validation should be executed. Defaults to true.
@@ -206,9 +206,9 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
*/
public function beforeValidate()
{
- if ($this->hasEventHandlers('onBeforeValidate')) {
+ if ($this->hasEventHandlers('beforeValidate')) {
$event = new ModelEvent($this);
- $this->onBeforeValidate($event);
+ $this->trigger('beforeValidate', $event);
return $event->isValid;
}
return true;
@@ -216,36 +216,18 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
/**
* This method is invoked after validation ends.
- * The default implementation raises the [[onAfterValidate]] event.
+ * The default implementation raises the `afterValidate` event.
* You may override this method to do postprocessing after validation.
* Make sure the parent implementation is invoked so that the event can be raised.
*/
public function afterValidate()
{
- if ($this->hasEventHandlers('onAfterValidate')) {
- $this->onAfterValidate(new Event($this));
+ if ($this->hasEventHandlers('afterValidate')) {
+ $this->trigger('afterValidate', new Event($this));
}
}
/**
- * This event is raised before the validation is performed.
- * @param ModelEvent $event the event parameter
- */
- public function onBeforeValidate($event)
- {
- $this->raiseEvent(__FUNCTION__, $event);
- }
-
- /**
- * This event is raised after the validation is performed.
- * @param Event $event the event parameter
- */
- public function onAfterValidate($event)
- {
- $this->raiseEvent(__FUNCTION__, $event);
- }
-
- /**
* Returns all the validators declared in [[rules()]].
*
* This method differs from [[getActiveValidators()]] in that the latter
diff --git a/framework/db/ar/ActiveRecord.php b/framework/db/ar/ActiveRecord.php
index bf7b21c..d6d504e 100644
--- a/framework/db/ar/ActiveRecord.php
+++ b/framework/db/ar/ActiveRecord.php
@@ -26,18 +26,19 @@ use yii\util\Text;
* @author Qiang Xue
* @since 2.0
*
- * @property array $attributes
+ * @property array $attributes attribute values indexed by attribute names
*
- * Events:
- * - beforeInsert. Raised before the record is saved.
+ * ActiveRecord provides a set of events for further customization:
+ *
+ * - `beforeInsert`. Raised before the record is saved.
* By setting [[\yii\base\ModelEvent::isValid]] to be false, the normal [[save()]] will be stopped.
- * - afterInsert. Raised after the record is saved.
- * - beforeUpdate. Raised before the record is saved.
+ * - `afterInsert`. Raised after the record is saved.
+ * - `beforeUpdate`. Raised before the record is saved.
* By setting [[\yii\base\ModelEvent::isValid]] to be false, the normal [[save()]] will be stopped.
- * - afterUpdate. Raised after the record is saved.
- * - beforeDelete. Raised before the record is deleted.
+ * - `afterUpdate`. Raised after the record is saved.
+ * - `beforeDelete`. Raised before the record is deleted.
* By setting [[\yii\base\ModelEvent::isValid]] to be false, the normal [[delete()]] process will be stopped.
- * - afterDelete. Raised after the record is deleted.
+ * - `afterDelete`. Raised after the record is deleted.
*
*/
abstract class ActiveRecord extends Model
@@ -832,7 +833,7 @@ abstract class ActiveRecord extends Model
/**
* This method is invoked before saving a record (after validation, if any).
- * The default implementation raises the {@link beforeSave} event.
+ * The default implementation raises the `beforeSave` event.
* You may override this method to do any preparation work for record saving.
* Use {@link isNewRecord} to determine whether the saving is
* for inserting or updating record.
@@ -848,7 +849,7 @@ abstract class ActiveRecord extends Model
/**
* This method is invoked after saving a record successfully.
- * The default implementation raises the {@link afterSave} event.
+ * The default implementation raises the `afterSave` event.
* You may override this method to do postprocessing after record saving.
* Make sure you call the parent implementation so that the event is raised properly.
*/
@@ -859,7 +860,7 @@ abstract class ActiveRecord extends Model
/**
* This method is invoked before saving a record (after validation, if any).
- * The default implementation raises the {@link beforeSave} event.
+ * The default implementation raises the `beforeSave` event.
* You may override this method to do any preparation work for record saving.
* Use {@link isNewRecord} to determine whether the saving is
* for inserting or updating record.
@@ -875,7 +876,7 @@ abstract class ActiveRecord extends Model
/**
* This method is invoked after saving a record successfully.
- * The default implementation raises the {@link afterSave} event.
+ * The default implementation raises the `afterSave` event.
* You may override this method to do postprocessing after record saving.
* Make sure you call the parent implementation so that the event is raised properly.
*/
@@ -886,7 +887,7 @@ abstract class ActiveRecord extends Model
/**
* This method is invoked before deleting a record.
- * The default implementation raises the {@link beforeDelete} event.
+ * The default implementation raises the `beforeDelete` event.
* You may override this method to do any preparation work for record deletion.
* Make sure you call the parent implementation so that the event is raised properly.
* @return boolean whether the record should be deleted. Defaults to true.
@@ -900,7 +901,7 @@ abstract class ActiveRecord extends Model
/**
* This method is invoked after deleting a record.
- * The default implementation raises the {@link afterDelete} event.
+ * The default implementation raises the `afterDelete` event.
* You may override this method to do postprocessing after the record is deleted.
* Make sure you call the parent implementation so that the event is raised properly.
*/
diff --git a/framework/logging/Logger.php b/framework/logging/Logger.php
index 5fd11a2..1adb347 100644
--- a/framework/logging/Logger.php
+++ b/framework/logging/Logger.php
@@ -17,6 +17,10 @@ namespace yii\logging;
* call [[flush]] to send logged messages to different log targets, such as
* file, email, Web.
*
+ * Logger provides a set of events for further customization:
+ *
+ * - `flush`. Raised on logs flush.
+ *
* @author Qiang Xue
* @since 2.0
*/
@@ -165,7 +169,7 @@ class Logger extends \yii\base\Component
/**
* Removes all recorded messages from the memory.
- * This method will raise an {@link onFlush} event.
+ * This method will raise a `flush` event.
* The attached event handlers can process the log messages before they are removed.
* @param boolean $export whether to notify log targets to export the filtered messages they have received.
*/
@@ -176,12 +180,12 @@ class Logger extends \yii\base\Component
}
/**
- * Raises an `onFlush` event.
+ * Raises a `flush` event.
* @param \yii\base\Event $event the event parameter
*/
public function onFlush($event)
{
- $this->raiseEvent('onFlush', $event);
+ $this->trigger('flush', $event);
}
/**