Skip to content

Commit

Permalink
Trigger with class constants
Browse files Browse the repository at this point in the history
  • Loading branch information
timkelty committed Feb 16, 2024
1 parent aedf5b1 commit abc2710
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
9 changes: 0 additions & 9 deletions src/EventEnum.php

This file was deleted.

3 changes: 3 additions & 0 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class Module extends \yii\base\Module implements \yii\base\BootstrapInterface
{
private Config $_config;

public const EVENT_BEFORE_UP = 'beforeUp';
public const EVENT_AFTER_UP = 'afterUp';

/**
* @inheritDoc
* @throws InvalidConfigException
Expand Down
8 changes: 5 additions & 3 deletions src/cli/controllers/UpController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
namespace craft\cloud\cli\controllers;

use Craft;
use craft\cloud\EventEnum;
use craft\console\Controller;
use craft\events\CancelableEvent;
use yii\console\ExitCode;

class UpController extends Controller
{
public const EVENT_BEFORE_UP = 'beforeUp';
public const EVENT_AFTER_UP = 'afterUp';

public function actionIndex(): int
{
$event = new CancelableEvent();
$this->trigger(EventEnum::BEFORE_UP->value, $event);
$this->trigger(self::EVENT_BEFORE_UP, $event);

if (!$event->isValid) {
return ExitCode::UNSPECIFIED_ERROR;
Expand All @@ -28,7 +30,7 @@ public function actionIndex(): int
}

$event = new CancelableEvent();
$this->trigger(EventEnum::AFTER_UP->value, $event);
$this->trigger(self::EVENT_AFTER_UP, $event);

if (!$event->isValid) {
return ExitCode::UNSPECIFIED_ERROR;
Expand Down

0 comments on commit abc2710

Please sign in to comment.