Skip to content

Commit

Permalink
Wrap events
Browse files Browse the repository at this point in the history
  • Loading branch information
timkelty committed Nov 17, 2023
1 parent 21e1408 commit 0997fd7
Showing 2 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/EventEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace craft\cloud;

enum EventEnum: string
{
case BEFORE_UP = 'beforeUp';
case AFTER_UP = 'afterUp';
}
18 changes: 17 additions & 1 deletion src/cli/controllers/UpController.php
Original file line number Diff line number Diff line change
@@ -3,19 +3,35 @@
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 function actionIndex(): int
{
$event = new CancelableEvent();
$this->trigger(EventEnum::BEFORE_UP->value, $event);

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

$this->run('/setup/php-session-table');
$this->run('/setup/db-cache-table');

// TODO: wrap with events
if (Craft::$app->getIsInstalled()) {
$this->run('/up');
$this->run('/clear-caches/cloud-static-caches');
}

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

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

return ExitCode::OK;

0 comments on commit 0997fd7

Please sign in to comment.