mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 05:48:11 +08:00
Fixes #14593: Added yii\db\Command::EVENT_AFTER_EXECUTE event that is triggered after command is executed
This commit is contained in:
committed by
GitHub
parent
5a6c48db3d
commit
a42bbd8f01
24
framework/db/AfterExecuteEvent.php
Normal file
24
framework/db/AfterExecuteEvent.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license http://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
namespace yii\db;
|
||||
|
||||
use yii\base\Event;
|
||||
|
||||
/**
|
||||
* AfterExecuteEvent represents the information available in [[Command::EVENT_AFTER_EXECUTE]].
|
||||
*
|
||||
* @author Alexander Makarov <sam@rmcreative.ru>
|
||||
* @since 2.0.14
|
||||
*/
|
||||
class AfterExecuteEvent extends Event
|
||||
{
|
||||
/**
|
||||
* @var Command command that was executed
|
||||
*/
|
||||
public $command;
|
||||
}
|
||||
@ -56,6 +56,12 @@ use yii\base\NotSupportedException;
|
||||
*/
|
||||
class Command extends Component
|
||||
{
|
||||
/**
|
||||
* @event Event an event that is triggered after a command is executed
|
||||
* @since 2.0.14
|
||||
*/
|
||||
const EVENT_AFTER_EXECUTE = 'afterExecute';
|
||||
|
||||
/**
|
||||
* @var Connection the DB connection that this command is associated with
|
||||
*/
|
||||
@ -1036,6 +1042,10 @@ class Command extends Component
|
||||
|
||||
$profile and Yii::endProfile($rawSql, __METHOD__);
|
||||
|
||||
$this->trigger(self::EVENT_AFTER_EXECUTE, new AfterExecuteEvent([
|
||||
'command' => $this,
|
||||
]));
|
||||
|
||||
$this->refreshTableSchema();
|
||||
|
||||
return $n;
|
||||
|
||||
Reference in New Issue
Block a user