Fixes #14593: Added yii\db\Command::EVENT_AFTER_EXECUTE event that is triggered after command is executed

This commit is contained in:
Alexander Makarov
2018-02-05 15:49:18 +07:00
committed by GitHub
parent 5a6c48db3d
commit a42bbd8f01
4 changed files with 41 additions and 0 deletions

View 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;
}

View File

@ -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;