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
7ff5f127
Commit
7ff5f127
authored
Mar 31, 2012
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed events to new style
parent
ed157ae1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
69 deletions
+24
-69
ActiveRecord.php
framework/db/ar/ActiveRecord.php
+24
-69
No files found.
framework/db/ar/ActiveRecord.php
View file @
7ff5f127
...
@@ -27,6 +27,18 @@ use yii\util\Text;
...
@@ -27,6 +27,18 @@ use yii\util\Text;
* @since 2.0
* @since 2.0
*
*
* @property array $attributes
* @property array $attributes
*
* Events:
* - 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.
* 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.
* By setting [[\yii\base\ModelEvent::isValid]] to be false, the normal [[delete()]] process will be stopped.
* - afterDelete. Raised after the record is deleted.
*
*/
*/
abstract
class
ActiveRecord
extends
Model
abstract
class
ActiveRecord
extends
Model
{
{
...
@@ -819,65 +831,8 @@ abstract class ActiveRecord extends Model
...
@@ -819,65 +831,8 @@ abstract class ActiveRecord extends Model
}
}
/**
/**
* This event is raised before the record is saved.
* By setting [[\yii\base\ModelEvent::isValid]] to be false, the normal [[save()]] will be stopped.
* @param \yii\base\ModelEvent $event the event parameter
*/
public
function
onBeforeInsert
(
$event
)
{
$this
->
raiseEvent
(
'onBeforeInsert'
,
$event
);
}
/**
* This event is raised after the record is saved.
* @param \yii\base\Event $event the event parameter
*/
public
function
onAfterInsert
(
$event
)
{
$this
->
raiseEvent
(
'onAfterInsert'
,
$event
);
}
/**
* This event is raised before the record is saved.
* By setting [[\yii\base\ModelEvent::isValid]] to be false, the normal [[save()]] will be stopped.
* @param \yii\base\ModelEvent $event the event parameter
*/
public
function
onBeforeUpdate
(
$event
)
{
$this
->
raiseEvent
(
'onBeforeUpdate'
,
$event
);
}
/**
* This event is raised after the record is saved.
* @param \yii\base\Event $event the event parameter
*/
public
function
onAfterUpdate
(
$event
)
{
$this
->
raiseEvent
(
'onAfterUpdate'
,
$event
);
}
/**
* This event is raised before the record is deleted.
* By setting [[\yii\base\ModelEvent::isValid]] to be false, the normal [[delete()]] process will be stopped.
* @param \yii\base\ModelEvent $event the event parameter
*/
public
function
onBeforeDelete
(
$event
)
{
$this
->
raiseEvent
(
'onBeforeDelete'
,
$event
);
}
/**
* This event is raised after the record is deleted.
* @param \yii\base\Event $event the event parameter
*/
public
function
onAfterDelete
(
$event
)
{
$this
->
raiseEvent
(
'onAfterDelete'
,
$event
);
}
/**
* 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
onB
eforeSave} event.
* The default implementation raises the {@link
b
eforeSave} 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.
...
@@ -887,24 +842,24 @@ abstract class ActiveRecord extends Model
...
@@ -887,24 +842,24 @@ abstract class ActiveRecord extends Model
public
function
beforeInsert
()
public
function
beforeInsert
()
{
{
$event
=
new
ModelEvent
(
$this
);
$event
=
new
ModelEvent
(
$this
);
$this
->
onBeforeInsert
(
$event
);
$this
->
trigger
(
'beforeInsert'
,
$event
);
return
$event
->
isValid
;
return
$event
->
isValid
;
}
}
/**
/**
* This method is invoked after saving a record successfully.
* This method is invoked after saving a record successfully.
* The default implementation raises the {@link
onA
fterSave} event.
* The default implementation raises the {@link
a
fterSave} 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.
*/
*/
public
function
afterInsert
()
public
function
afterInsert
()
{
{
$this
->
onAfterInsert
(
new
Event
(
$this
));
$this
->
trigger
(
'afterInsert'
,
new
Event
(
$this
));
}
}
/**
/**
* 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
onB
eforeSave} event.
* The default implementation raises the {@link
b
eforeSave} 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.
...
@@ -914,24 +869,24 @@ abstract class ActiveRecord extends Model
...
@@ -914,24 +869,24 @@ abstract class ActiveRecord extends Model
public
function
beforeUpdate
()
public
function
beforeUpdate
()
{
{
$event
=
new
ModelEvent
(
$this
);
$event
=
new
ModelEvent
(
$this
);
$this
->
onBeforeUpdate
(
$event
);
$this
->
trigger
(
'beforeUpdate'
,
$event
);
return
$event
->
isValid
;
return
$event
->
isValid
;
}
}
/**
/**
* This method is invoked after saving a record successfully.
* This method is invoked after saving a record successfully.
* The default implementation raises the {@link
onA
fterSave} event.
* The default implementation raises the {@link
a
fterSave} 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.
*/
*/
public
function
afterUpdate
()
public
function
afterUpdate
()
{
{
$this
->
onAfterUpdate
(
new
Event
(
$this
));
$this
->
trigger
(
'afterUpdate'
,
new
Event
(
$this
));
}
}
/**
/**
* This method is invoked before deleting a record.
* This method is invoked before deleting a record.
* The default implementation raises the {@link
onB
eforeDelete} event.
* The default implementation raises the {@link
b
eforeDelete} 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.
...
@@ -939,19 +894,19 @@ abstract class ActiveRecord extends Model
...
@@ -939,19 +894,19 @@ abstract class ActiveRecord extends Model
public
function
beforeDelete
()
public
function
beforeDelete
()
{
{
$event
=
new
ModelEvent
(
$this
);
$event
=
new
ModelEvent
(
$this
);
$this
->
onBeforeDelete
(
$event
);
$this
->
trigger
(
'beforeDelete'
,
$event
);
return
$event
->
isValid
;
return
$event
->
isValid
;
}
}
/**
/**
* This method is invoked after deleting a record.
* This method is invoked after deleting a record.
* The default implementation raises the {@link
onA
fterDelete} event.
* The default implementation raises the {@link
a
fterDelete} 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.
*/
*/
public
function
afterDelete
()
public
function
afterDelete
()
{
{
$this
->
onAfterDelete
(
new
Event
(
$this
));
$this
->
trigger
(
'afterDelete'
,
new
Event
(
$this
));
}
}
/**
/**
...
...
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