Skip to content

Commit

Permalink
Merge pull request #1146 from ga-devfront/feat/middlware-page-post-up…
Browse files Browse the repository at this point in the history
…date

[MIDDLEWARE] page post update
  • Loading branch information
ga-devfront authored Feb 4, 2025
2 parents 94f3197 + 9c0cbc7 commit 8c8c4fd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
21 changes: 21 additions & 0 deletions classes/Router/Middlewares/UpdateLogExists.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace PrestaShop\Module\AutoUpgrade\Router\Middlewares;

use PrestaShop\Module\AutoUpgrade\Router\Routes;
use PrestaShop\Module\AutoUpgrade\Task\TaskType;

class UpdateLogExists extends AbstractMiddleware
{
public function process(): ?string
{
$activeUpdateLogPath = $this->upgradeContainer->getLogsService()->getLogsPath(TaskType::TASK_TYPE_UPDATE);

if ($activeUpdateLogPath === null
|| !$this->upgradeContainer->getFileSystem()->exists($activeUpdateLogPath)) {
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 8c8c4fd

Please sign in to comment.