Skip to content

Commit

Permalink
Merge branch 'feature/cld-369-add-static-cache-clearing-utility'
Browse files Browse the repository at this point in the history
  • Loading branch information
timkelty committed Nov 17, 2023
2 parents c97cd71 + 0997fd7 commit 52a7696
Show file tree
Hide file tree
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
Expand Up @@ -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;
Expand Down

0 comments on commit 52a7696

Please sign in to comment.