Skip to content

Commit

Permalink
feat(upgrade): bump codebase to latest sylius v1
Browse files Browse the repository at this point in the history
  • Loading branch information
maxperei committed Dec 24, 2024
1 parent 73c4266 commit 8285c6a
Show file tree
Hide file tree
Showing 26 changed files with 78 additions and 75 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ jobs:
fail-fast: false
matrix:
php:
- 8.1
- 8.2
- 8.3
symfony:
- '5.4.*'
- '6.3.*'
- '6.4.*'
env:
APP_ENV: test
steps:
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/sylius.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,16 @@ jobs:
fail-fast: false
matrix:
php:
- 8.1
- 8.2
- 8.3
sylius:
- 1.10.0
- 1.12.0
- 1.13.0
- 1.14.0
symfony:
- 5.4
- 6.3
- 6.4
node:
- 14.x
exclude:
-
sylius: 1.10.0
symfony: 6.3
env:
APP_ENV: test
package-name: synolia/sylius-maintenance-plugin
Expand Down
19 changes: 10 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
SHELL=/bin/bash
COMPOSER_ROOT=composer
TEST_DIRECTORY=tests/Application
CONSOLE=cd tests/Application && php bin/console -e test
COMPOSER=cd tests/Application && composer
YARN=cd tests/Application && yarn
INSTALL_DIRECTORY=install/Application
CONSOLE=cd ${TEST_DIRECTORY} && php bin/console -e test
COMPOSER=cd ${TEST_DIRECTORY} && composer
YARN=cd ${TEST_DIRECTORY} && yarn

SYLIUS_VERSION=1.12.0
SYMFONY_VERSION=6.1
PHP_VERSION=8.1
SYLIUS_VERSION=1.14.0
SYMFONY_VERSION=6.4
PHP_VERSION=8.2
PLUGIN_NAME=synolia/sylius-maintenance-plugin

###
Expand All @@ -19,10 +20,10 @@ install: sylius ## Install Plugin on Sylius [SYLIUS_VERSION=1.12.0] [SYMFONY_VER
.PHONY: install

reset: ## Remove dependencies
ifneq ("$(wildcard tests/Application/bin/console)","")
ifneq ("$(wildcard ${TEST_DIRECTORY}/bin/console)","")
${CONSOLE} doctrine:database:drop --force --if-exists || true
endif
rm -rf tests/Application
rm -rf ${TEST_DIRECTORY}
.PHONY: reset

phpunit: phpunit-configure phpunit-run ## Run PHPUnit
Expand Down Expand Up @@ -59,7 +60,7 @@ install-plugin:
${COMPOSER} config minimum-stability "dev"
${COMPOSER} config prefer-stable true
${COMPOSER} req ${PLUGIN_NAME}:* --prefer-source --no-scripts
cp -r install/Application tests
cp -r ${INSTALL_DIRECTORY} tests

install-sylius:
${CONSOLE} sylius:install -n -s default
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

| | Version |
|:-------|:--------|
| PHP | ^8.0 |
| Sylius | ^1.10 |
| PHP | ^8.2 |
| Sylius | ^1.12 |

## Installation

Expand All @@ -44,14 +44,14 @@

``` yaml
imports:
- { resource: "@SynoliaSyliusMaintenancePlugin/Resources/config/config.yaml" }
- { resource: "@SynoliaSyliusMaintenancePlugin/config/config.yaml" }
```
3. Import routing in your `config/routes.yaml` file:
``` yaml
synolia_maintenance:
resource: "@SynoliaSyliusMaintenancePlugin/Resources/config/admin_routing.yaml"
resource: "@SynoliaSyliusMaintenancePlugin/config/admin_routing.yaml"
prefix: '/%sylius_admin.path_name%'
```
Expand Down
44 changes: 21 additions & 23 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,38 @@
],
"license": "EUPL-1.2",
"require": {
"php": "^8.0",
"php": "^8.2",
"jaybizzle/crawler-detect": "^1.2",
"sylius/sylius": "^1.10",
"sylius/sylius": "^1.12",
"webmozart/assert": "^1.11"
},
"require-dev": {
"dbrekelmans/bdi": "1.0",
"friendsoftwig/twigcs": "6.1.0",
"phpmd/phpmd": "2.13.0",
"phpro/grumphp": "1.15.0",
"phpspec/phpspec": "7.3.0",
"phpstan/extension-installer": "1.2.0",
"phpstan/phpstan": "1.9.7",
"phpstan/phpstan-doctrine": "1.3.29",
"phpstan/phpstan-phpunit": "1.3.3",
"phpstan/phpstan-strict-rules": "1.4.4",
"phpstan/phpstan-webmozart-assert": "1.2.2",
"phpunit/phpunit": "9.5.27",
"rector/rector": "^0.15.2",
"sylius-labs/coding-standard": "4.3.0",
"symfony/browser-kit": "6.0.11",
"symfony/debug-bundle": "6.0.11",
"symfony/dotenv": "6.0.5",
"symfony/intl": "6.0.15",
"symfony/panther": "2.0.1",
"symfony/web-profiler-bundle": "6.0.17"
"dbrekelmans/bdi": "^1.0",
"friendsoftwig/twigcs": "^6.4.0",
"phpmd/phpmd": "^2.13",
"phpro/grumphp": "^2.0",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-strict-rules": "^1.6",
"phpstan/phpstan-webmozart-assert": "^1.2",
"phpunit/phpunit": "^9.5",
"rector/rector": "^1.2",
"sylius-labs/coding-standard": "^4.3",
"symfony/browser-kit": "^6.4",
"symfony/debug-bundle": "^6.4",
"symfony/dotenv": "^6.4",
"symfony/intl": "^6.4",
"symfony/panther": "^2.0",
"symfony/web-profiler-bundle": "^6.4"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"symfony/thanks": true,
"phpro/grumphp": true,
"phpstan/extension-installer": true
"phpstan/extension-installer": true,
"php-http/discovery": true
}
},
"autoload": {
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
imports:
- { resource: "@SynoliaSyliusMaintenancePlugin/config/services.yaml" }
15 changes: 3 additions & 12 deletions src/Resources/config/services.yaml → config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,9 @@ services:
- { name: !php/const Synolia\SyliusMaintenancePlugin\Checker\IsMaintenanceCheckerInterface::TAG_ID }

Synolia\SyliusMaintenancePlugin\:
resource: '../../*'
exclude: '../../{Controller,Migrations,SynoliaSyliusMaintenancePlugin.php}'
resource: '../src/*'
exclude: '../src/{Controller,Migrations,SynoliaSyliusMaintenancePlugin.php}'

Synolia\SyliusMaintenancePlugin\Controller\:
resource: '../../Controller/*'
resource: '../src/Controller/*'
tags: ['controller.service_arguments']

Synolia\SyliusMaintenancePlugin\Menu\AdminMenuListener:
tags:
- { name: kernel.event_listener, event: sylius.menu.admin.main, method: addAdminMenuItems }

Synolia\SyliusMaintenancePlugin\Voter\IsMaintenanceVoterInterface:
class: Synolia\SyliusMaintenancePlugin\Voter\IsMaintenanceVoter
arguments:
- !tagged_iterator { tag: !php/const Synolia\SyliusMaintenancePlugin\Checker\IsMaintenanceCheckerInterface::TAG_ID }
2 changes: 1 addition & 1 deletion install/Application/config/packages/maintenance.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
imports:
- { resource: "@SynoliaSyliusMaintenancePlugin/Resources/config/config.yaml" }
- { resource: "@SynoliaSyliusMaintenancePlugin/config/config.yaml" }
2 changes: 1 addition & 1 deletion install/Application/config/routes/maintenance.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
synolia_maintenance:
resource: "@SynoliaSyliusMaintenancePlugin/Resources/config/admin_routing.yaml"
resource: "@SynoliaSyliusMaintenancePlugin/config/admin_routing.yaml"
prefix: '/%sylius_admin.path_name%'
1 change: 1 addition & 0 deletions ruleset/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ parameters:
level: max
reportUnmatchedIgnoredErrors: false
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
bootstrapFiles:
- ../vendor/autoload.php
excludePaths:
Expand Down
1 change: 1 addition & 0 deletions src/Checker/ScheduledChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ private function isActuallyScheduledMaintenance(MaintenanceConfiguration $mainte
if ($endDate !== null && $startDate === null && ($now <= $endDate)) {
return true;
}

// No schedule date
return false;
}
Expand Down
9 changes: 7 additions & 2 deletions src/Command/DisableMaintenanceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Synolia\SyliusMaintenancePlugin\Command;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand All @@ -14,6 +15,10 @@
use Synolia\SyliusMaintenancePlugin\Factory\MaintenanceConfigurationFactory;
use Synolia\SyliusMaintenancePlugin\FileManager\ConfigurationFileManager;

#[AsCommand(
name: 'maintenance:disable',
description: 'Disable maintenance plugin',
)]
final class DisableMaintenanceCommand extends Command
{
protected static $defaultName = 'maintenance:disable';
Expand Down Expand Up @@ -48,11 +53,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->configurationFileManager->deleteMaintenanceFile();
$output->writeln($this->translator->trans('maintenance.ui.message_reset'));

return 0;
return Command::SUCCESS;
}

$output->writeln($this->translator->trans('maintenance.ui.message_disabled'));

return 0;
return Command::SUCCESS;
}
}
5 changes: 5 additions & 0 deletions src/Command/EnableMaintenanceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
use Sylius\Component\Core\Model\ChannelInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -17,6 +18,10 @@
use Synolia\SyliusMaintenancePlugin\FileManager\ConfigurationFileManager;
use Synolia\SyliusMaintenancePlugin\Model\MaintenanceConfiguration;

#[AsCommand(
name: 'maintenance:enable',
description: 'Turn your website under maintenance.',
)]
final class EnableMaintenanceCommand extends Command
{
protected static $defaultName = 'maintenance:enable';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class SynoliaSyliusMaintenanceExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader = new YamlFileLoader($container, new FileLocator(\dirname(__DIR__, 2) . '/config'));

$loader->load('services.yaml');
}
Expand Down
2 changes: 2 additions & 0 deletions src/Menu/AdminMenuListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

use Knp\Menu\ItemInterface;
use Sylius\Bundle\UiBundle\Menu\Event\MenuBuilderEvent;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;

#[AsEventListener(event: 'sylius.menu.admin.main', method: 'addAdminMenuItems')]
final class AdminMenuListener
{
public function addAdminMenuItems(MenuBuilderEvent $event): void
Expand Down
2 changes: 0 additions & 2 deletions src/Resources/config/config.yaml

This file was deleted.

1 change: 0 additions & 1 deletion src/Resources/config/shop_routing.yaml

This file was deleted.

5 changes: 5 additions & 0 deletions src/SynoliaSyliusMaintenancePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@
final class SynoliaSyliusMaintenancePlugin extends Bundle
{
use SyliusPluginTrait;

public function getPath(): string
{
return \dirname(__DIR__);
}
}
14 changes: 7 additions & 7 deletions src/Voter/IsMaintenanceVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@

namespace Synolia\SyliusMaintenancePlugin\Voter;

use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
use Symfony\Component\HttpFoundation\Request;
use Synolia\SyliusMaintenancePlugin\Checker\IsMaintenanceCheckerInterface;
use Synolia\SyliusMaintenancePlugin\Model\MaintenanceConfiguration;

class IsMaintenanceVoter implements IsMaintenanceVoterInterface
{
/** @var array<\Synolia\SyliusMaintenancePlugin\Checker\IsMaintenanceCheckerInterface> */
private array $isMaintenanceCheckers;

public function __construct(\Traversable $checkers)
{
$this->isMaintenanceCheckers = iterator_to_array($checkers);
public function __construct(
#[TaggedIterator(IsMaintenanceCheckerInterface::TAG_ID)]
private iterable $checkers,
) {
}

public function isMaintenance(MaintenanceConfiguration $configuration, Request $request): bool
{
foreach ($this->isMaintenanceCheckers as $checker) {
foreach ($this->checkers as $checker) {
$result = $checker->isMaintenance($configuration, $request);

// As soon as a voter says that the site is accessible then we deactivate the maintenance
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Sylius\Component\Core\Test\Services\DefaultChannelFactory;
use Symfony\Component\Yaml\Yaml;

final class MulitChannelMaintenanceTest extends AbstractWebTestCase
final class MultiChannelMaintenanceTest extends AbstractWebTestCase
{
protected function setUp(): void
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 8285c6a

Please sign in to comment.