Skip to content

Commit

Permalink
Added events on running actions
Browse files Browse the repository at this point in the history
  • Loading branch information
omnilight committed Apr 24, 2015
1 parent 5df9a3b commit 5f1603a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
use GuzzleHttp\Client as HttpClient;
use Symfony\Component\Process\Process;
use yii\base\Application;
use yii\base\Component;
use yii\base\InvalidCallException;
use yii\base\Object;
use yii\mail\MailerInterface;


/**
* Class Event
*/
class Event extends Object
class Event extends Component
{
const EVENT_BEFORE_RUN = 'beforeRun';
const EVENT_AFTER_RUN = 'afterRun';

/**
* Command string
* @var string
Expand Down Expand Up @@ -88,11 +91,13 @@ public function __construct($command, $config = [])
*/
public function run(Application $app)
{
$this->trigger(self::EVENT_BEFORE_RUN);
if (count($this->_afterCallbacks) > 0) {
$this->runCommandInForeground($app);
} else {
$this->runCommandInBackground($app);
}
$this->trigger(self::EVENT_AFTER_RUN);
}

/**
Expand Down

0 comments on commit 5f1603a

Please sign in to comment.