Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
2dabbb8c
Commit
2dabbb8c
authored
Mar 31, 2012
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.yiisoft.com:yii2
Conflicts: framework/base/Model.php
parents
a705fb4e
e790827f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
37 deletions
+42
-37
Application.php
framework/base/Application.php
+20
-20
ActiveRecord.php
framework/db/ar/ActiveRecord.php
+15
-14
Logger.php
framework/logging/Logger.php
+7
-3
No files found.
framework/base/Application.php
View file @
2dabbb8c
...
@@ -38,9 +38,9 @@ namespace yii\base;
...
@@ -38,9 +38,9 @@ namespace yii\base;
* <li>load application configuration;</li>
* <li>load application configuration;</li>
* <li>set up class autoloader and error handling;</li>
* <li>set up class autoloader and error handling;</li>
* <li>load static application components;</li>
* <li>load static application components;</li>
* <li>{@link
onBeginRequest}: preprocess the user request;
</li>
* <li>{@link
beforeRequest}: preprocess the user request; `beforeRequest` event raised.
</li>
* <li>{@link processRequest}: process the user request;</li>
* <li>{@link processRequest}: process the user request;</li>
* <li>{@link
onEndRequest}: postprocess the user request;
</li>
* <li>{@link
afterRequest}: postprocess the user request; `afterRequest` event raised.
</li>
* </ol>
* </ol>
*
*
* Starting from lifecycle 3, if a PHP error or an uncaught exception occurs,
* Starting from lifecycle 3, if a PHP error or an uncaught exception occurs,
...
@@ -153,12 +153,12 @@ abstract class Application extends Module
...
@@ -153,12 +153,12 @@ abstract class Application extends Module
*/
*/
public
function
run
()
public
function
run
()
{
{
if
(
$this
->
hasEventHandlers
(
'
onBegin
Request'
))
{
if
(
$this
->
hasEventHandlers
(
'
before
Request'
))
{
$this
->
onBegin
Request
(
new
CEvent
(
$this
));
$this
->
before
Request
(
new
CEvent
(
$this
));
}
}
$this
->
processRequest
();
$this
->
processRequest
();
if
(
$this
->
hasEventHandlers
(
'
onEnd
Request'
))
{
if
(
$this
->
hasEventHandlers
(
'
after
Request'
))
{
$this
->
onEnd
Request
(
new
CEvent
(
$this
));
$this
->
after
Request
(
new
CEvent
(
$this
));
}
}
}
}
...
@@ -182,22 +182,22 @@ abstract class Application extends Module
...
@@ -182,22 +182,22 @@ abstract class Application extends Module
/**
/**
* Raised right BEFORE the application processes the request.
* Raised right BEFORE the application processes the request.
* @param
C
Event $event the event parameter
* @param Event $event the event parameter
*/
*/
public
function
onBegin
Request
(
$event
)
public
function
before
Request
(
$event
)
{
{
$this
->
raiseEvent
(
'onBegin
Request'
,
$event
);
$this
->
trigger
(
'before
Request'
,
$event
);
}
}
/**
/**
* Raised right AFTER the application processes the request.
* Raised right AFTER the application processes the request.
* @param
C
Event $event the event parameter
* @param Event $event the event parameter
*/
*/
public
function
onEnd
Request
(
$event
)
public
function
after
Request
(
$event
)
{
{
if
(
!
$this
->
_ended
)
{
if
(
!
$this
->
_ended
)
{
$this
->
_ended
=
true
;
$this
->
_ended
=
true
;
$this
->
raiseEvent
(
'onEnd
Request'
,
$event
);
$this
->
trigger
(
'after
Request'
,
$event
);
}
}
}
}
...
@@ -687,7 +687,7 @@ abstract class Application extends Module
...
@@ -687,7 +687,7 @@ abstract class Application extends Module
* This method is implemented as a PHP exception handler. It requires
* This method is implemented as a PHP exception handler. It requires
* that constant YII_ENABLE_EXCEPTION_HANDLER be defined true.
* 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
* If the exception is not handled by any event handler, it will call
* {@link getErrorHandler errorHandler} to process the exception.
* {@link getErrorHandler errorHandler} to process the exception.
*
*
...
@@ -757,7 +757,7 @@ abstract class Application extends Module
...
@@ -757,7 +757,7 @@ abstract class Application extends Module
* This method is implemented as a PHP error handler. It requires
* This method is implemented as a PHP error handler. It requires
* that constant YII_ENABLE_ERROR_HANDLER be defined true.
* 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
* If the error is not handled by any event handler, it will call
* {@link getErrorHandler errorHandler} to process the error.
* {@link getErrorHandler errorHandler} to process the error.
*
*
...
@@ -844,31 +844,31 @@ abstract class Application extends Module
...
@@ -844,31 +844,31 @@ abstract class Application extends Module
/**
/**
* Raised when an uncaught PHP exception occurs.
* Raised when an uncaught PHP exception occurs.
*
*
* An event handler can set the {@link
C
ExceptionEvent::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
* property of the event parameter to be true to indicate no further error
* handling is needed. Otherwise, the {@link getErrorHandler errorHandler}
* handling is needed. Otherwise, the {@link getErrorHandler errorHandler}
* application component will continue processing the error.
* application component will continue processing the error.
*
*
* @param
C
ExceptionEvent $event event parameter
* @param ExceptionEvent $event event parameter
*/
*/
public
function
onException
(
$event
)
public
function
onException
(
$event
)
{
{
$this
->
raiseEvent
(
'onE
xception'
,
$event
);
$this
->
trigger
(
'e
xception'
,
$event
);
}
}
/**
/**
* Raised when a PHP execution error occurs.
* Raised when a PHP execution error occurs.
*
*
* An event handler can set the {@link
C
ErrorEvent::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
* property of the event parameter to be true to indicate no further error
* handling is needed. Otherwise, the {@link getErrorHandler errorHandler}
* handling is needed. Otherwise, the {@link getErrorHandler errorHandler}
* application component will continue processing the error.
* application component will continue processing the error.
*
*
* @param
C
ErrorEvent $event event parameter
* @param ErrorEvent $event event parameter
*/
*/
public
function
onError
(
$event
)
public
function
onError
(
$event
)
{
{
$this
->
raiseEvent
(
'onE
rror'
,
$event
);
$this
->
trigger
(
'e
rror'
,
$event
);
}
}
/**
/**
...
...
framework/db/ar/ActiveRecord.php
View file @
2dabbb8c
...
@@ -26,18 +26,19 @@ use yii\util\Text;
...
@@ -26,18 +26,19 @@ use yii\util\Text;
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
* @since 2.0
*
*
* @property array $attributes
* @property array $attributes
attribute values indexed by attribute names
*
*
* Events:
* ActiveRecord provides a set of events for further customization:
* - beforeInsert. Raised before the record is saved.
*
* - `beforeInsert`. Raised before the record is saved.
* By setting [[\yii\base\ModelEvent::isValid]] to be false, the normal [[save()]] will be stopped.
* By setting [[\yii\base\ModelEvent::isValid]] to be false, the normal [[save()]] will be stopped.
* -
afterInsert
. Raised after the record is saved.
* -
`afterInsert`
. Raised after the record is saved.
* -
beforeUpdate
. Raised before 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.
* By setting [[\yii\base\ModelEvent::isValid]] to be false, the normal [[save()]] will be stopped.
* -
afterUpdate
. Raised after the record is saved.
* -
`afterUpdate`
. Raised after the record is saved.
* -
beforeDelete
. Raised before the record is deleted.
* -
`beforeDelete`
. Raised before the record is deleted.
* By setting [[\yii\base\ModelEvent::isValid]] to be false, the normal [[delete()]] process will be stopped.
* 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
abstract
class
ActiveRecord
extends
Model
...
@@ -832,7 +833,7 @@ 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).
* 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.
* You may override this method to do any preparation work for record saving.
* Use {@link isNewRecord} to determine whether the saving is
* Use {@link isNewRecord} to determine whether the saving is
* for inserting or updating record.
* for inserting or updating record.
...
@@ -848,7 +849,7 @@ abstract class ActiveRecord extends Model
...
@@ -848,7 +849,7 @@ abstract class ActiveRecord extends Model
/**
/**
* This method is invoked after saving a record successfully.
* 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.
* 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.
* Make sure you call the parent implementation so that the event is raised properly.
*/
*/
...
@@ -859,7 +860,7 @@ abstract class ActiveRecord extends Model
...
@@ -859,7 +860,7 @@ abstract class ActiveRecord extends Model
/**
/**
* This method is invoked before saving a record (after validation, if any).
* 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.
* You may override this method to do any preparation work for record saving.
* Use {@link isNewRecord} to determine whether the saving is
* Use {@link isNewRecord} to determine whether the saving is
* for inserting or updating record.
* for inserting or updating record.
...
@@ -875,7 +876,7 @@ abstract class ActiveRecord extends Model
...
@@ -875,7 +876,7 @@ abstract class ActiveRecord extends Model
/**
/**
* This method is invoked after saving a record successfully.
* 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.
* 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.
* Make sure you call the parent implementation so that the event is raised properly.
*/
*/
...
@@ -886,7 +887,7 @@ abstract class ActiveRecord extends Model
...
@@ -886,7 +887,7 @@ abstract class ActiveRecord extends Model
/**
/**
* This method is invoked before deleting a record.
* 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.
* 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.
* 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.
* @return boolean whether the record should be deleted. Defaults to true.
...
@@ -900,7 +901,7 @@ abstract class ActiveRecord extends Model
...
@@ -900,7 +901,7 @@ abstract class ActiveRecord extends Model
/**
/**
* This method is invoked after deleting a record.
* 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.
* 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.
* Make sure you call the parent implementation so that the event is raised properly.
*/
*/
...
...
framework/logging/Logger.php
View file @
2dabbb8c
...
@@ -16,6 +16,10 @@ namespace yii\logging;
...
@@ -16,6 +16,10 @@ namespace yii\logging;
* call [[flush]] to send logged messages to different log targets, such as
* call [[flush]] to send logged messages to different log targets, such as
* file, email, Web.
* file, email, Web.
*
*
* Logger provides a set of events for further customization:
*
* - `flush`. Raised on logs flush.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
* @since 2.0
*/
*/
...
@@ -164,7 +168,7 @@ class Logger extends \yii\base\Component
...
@@ -164,7 +168,7 @@ class Logger extends \yii\base\Component
/**
/**
* Removes all recorded messages from the memory.
* Removes all recorded messages from the memory.
* This method will raise a
n {@link onFlush}
event.
* This method will raise a
`flush`
event.
* The attached event handlers can process the log messages before they are removed.
* 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.
* @param boolean $export whether to notify log targets to export the filtered messages they have received.
*/
*/
...
@@ -175,12 +179,12 @@ class Logger extends \yii\base\Component
...
@@ -175,12 +179,12 @@ class Logger extends \yii\base\Component
}
}
/**
/**
* Raises a
n `onF
lush` event.
* Raises a
`f
lush` event.
* @param \yii\base\Event $event the event parameter
* @param \yii\base\Event $event the event parameter
*/
*/
public
function
onFlush
(
$event
)
public
function
onFlush
(
$event
)
{
{
$this
->
raiseEvent
(
'onF
lush'
,
$event
);
$this
->
trigger
(
'f
lush'
,
$event
);
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment