Skip to content

Commit

Permalink
feat: add middleware for update page post update
Browse files Browse the repository at this point in the history
  • Loading branch information
ga-devfront committed Jan 30, 2025
1 parent 7c1b3f7 commit 5bb496b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions classes/Router/Middlewares/UpdateLogExists.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace PrestaShop\Module\AutoUpgrade\Router\Middlewares;

use PrestaShop\Module\AutoUpgrade\Router\Routes;

class UpdateLogExists extends AbstractMiddleware
{
public function process(): ?string
{
if ($this->upgradeContainer->getLogsState()->getActiveUpdateLogFile() === null) {
return Routes::HOME_PAGE;
}

return null;
}
}
4 changes: 4 additions & 0 deletions classes/Router/RoutesConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use PrestaShop\Module\AutoUpgrade\Controller\UpdatePageVersionChoiceController;
use PrestaShop\Module\AutoUpgrade\Router\Middlewares\LocalChannelXmlAndZipAreValid;
use PrestaShop\Module\AutoUpgrade\Router\Middlewares\UpdateIsConfigured;
use PrestaShop\Module\AutoUpgrade\Router\Middlewares\UpdateLogExists;

class RoutesConfig
{
Expand Down Expand Up @@ -132,6 +133,9 @@ class RoutesConfig
Routes::UPDATE_PAGE_POST_UPDATE => [
'controller' => UpdatePagePostUpdateController::class,
'method' => 'index',
'middleware' => [
UpdateLogExists::class,
],
],
Routes::UPDATE_STEP_POST_UPDATE => [
'controller' => UpdatePagePostUpdateController::class,
Expand Down

0 comments on commit 5bb496b

Please sign in to comment.