Skip to content

Commit

Permalink
[Maintenance] Slight fixes of 1.13 support
Browse files Browse the repository at this point in the history
  • Loading branch information
NoResponseMate committed Mar 1, 2024
1 parent 50db970 commit 41c6234
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 92 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
wkhtmltopdf: ["0.12.6-1"]
state_machine_adapter: [ "winzou_state_machine", "symfony_workflow" ]


include:
-
php: "8.1"
Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ From Administrator's point of view, every Refund request results in creating two
WKHTMLTOPDF_PATH=/usr/local/bin/wkhtmltopdf # Change this! :)
```
1. If you are using the symfony workflows instead winzou_state_machine please import configuration:
```yaml
imports:
- { resource: "@SyliusRefundPlugin/Resources/config/app/workflow.yaml" }
```
#### Beware!
This installation instruction assumes that you're using Symfony Flex. If you don't, take a look at the
Expand Down
2 changes: 2 additions & 0 deletions UPGRADE-1.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
constructors of `Sylius\RefundPlugin\Converter\LineItem\OrderItemUnitLineItemsConverter` and
`Sylius\RefundPlugin\Converter\LineItem\ShipmentLineItemsConverter`
has been deprecated and will be prohibited in 2.0.

5. The support for PHP 8.0 and Sylius 1.11 has been dropped.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"myclabs/php-enum": "^1.7",
"php-http/message-factory": "^1.1",
"sylius/resource-bundle": "^1.9",
"sylius/sylius": "~1.12.0 || ~1.13.x-dev",
"sylius/sylius": "~1.13.x-dev",
"symfony/messenger": "^5.4.21 || ^6.4"
},
"require-dev": {
Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/app/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
imports:
- { resource: "@SyliusRefundPlugin/Resources/config/app/events.yaml" }
- { resource: "@SyliusRefundPlugin/Resources/config/app/workflow.yaml" }

parameters:
sylius_refund.credit_memo_save_path: "%kernel.project_dir%/private/credit_memos/"
Expand Down
55 changes: 4 additions & 51 deletions tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,15 @@
namespace Tests\Sylius\RefundPlugin\Application;

use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer;
use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel;
use Sylius\Bundle\CoreBundle\SyliusCoreBundle;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

final class Kernel extends BaseKernel
{
use MicroKernelTrait;

private const CONFIG_EXTS = '.{php,xml,yaml,yml}';

private const IGNORED_SERVICES_DURING_CLEANUP = [
'kernel',
'http_kernel',
'liip_imagine.mime_type_guesser',
'liip_imagine.extension_guesser',
];

public function getCacheDir(): string
{
return $this->getProjectDir() . '/var/cache/' . $this->environment;
Expand All @@ -44,26 +31,6 @@ public function registerBundles(): iterable
}
}

protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
foreach ($this->getBundleListFiles() as $file) {
$container->addResource(new FileResource($file));
}

$container->setParameter('container.dumper.inline_class_loader', true);

foreach ($this->getConfigurationDirectories() as $confDir) {
$this->loadContainerConfiguration($loader, $confDir);
}
}

protected function configureRoutes(RoutingConfigurator $routes): void
{
foreach ($this->getConfigurationDirectories() as $confDir) {
$this->loadRoutesConfiguration($routes, $confDir);
}
}

protected function getContainerBaseClass(): string
{
if ($this->isTestEnvironment() && class_exists(MockerContainer::class)) {
Expand All @@ -75,22 +42,7 @@ protected function getContainerBaseClass(): string

private function isTestEnvironment(): bool
{
return 0 === strpos($this->getEnvironment(), 'test');
}

private function loadContainerConfiguration(LoaderInterface $loader, string $confDir): void
{
$loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob');
$loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob');
$loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob');
$loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob');
}

private function loadRoutesConfiguration(RoutingConfigurator $routes, string $confDir): void
{
$routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS);
$routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS);
$routes->import($confDir . '/{routes}' . self::CONFIG_EXTS);
return str_starts_with($this->getEnvironment(), 'test');
}

/**
Expand All @@ -100,6 +52,7 @@ private function registerBundlesFromFile(string $bundlesFile): iterable
{
$contents = require $bundlesFile;

/** @var BundleInterface $class */
foreach ($contents as $class => $envs) {
if (isset($envs['all']) || isset($envs[$this->environment])) {
yield new $class();
Expand Down Expand Up @@ -130,7 +83,7 @@ private function getConfigurationDirectories(): array
{
$directories = [
$this->getProjectDir() . '/config',
$this->getProjectDir() . '/config/sylius/' . SyliusKernel::MAJOR_VERSION . '.' . SyliusKernel::MINOR_VERSION,
$this->getProjectDir() . '/config/sylius/' . SyliusCoreBundle::MAJOR_VERSION . '.' . SyliusCoreBundle::MINOR_VERSION,
];

return array_filter($directories, 'file_exists');
Expand Down
11 changes: 3 additions & 8 deletions tests/Application/config/bundles.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php

use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel;
use Sylius\Bundle\CoreBundle\SyliusCoreBundle;

$bundles = [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
League\FlysystemBundle\FlysystemBundle::class => ['all' => true],
Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true],
Sylius\Bundle\MoneyBundle\SyliusMoneyBundle::class => ['all' => true],
Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle::class => ['all' => true],
Expand Down Expand Up @@ -61,13 +62,7 @@
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
];

if (SyliusKernel::MINOR_VERSION > 11) {
$bundles[League\FlysystemBundle\FlysystemBundle::class] = ['all' => true];
} else {
$bundles[Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class] = ['all' => true];
}

if (SyliusKernel::MINOR_VERSION == 13) {
if (SyliusCoreBundle::VERSION_ID >= '11300') {
$bundles[Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class] = ['all' => true];
}

Expand Down
3 changes: 0 additions & 3 deletions tests/Application/config/sylius/1.12/_sylius.yaml

This file was deleted.

21 changes: 0 additions & 21 deletions tests/Application/config/sylius/1.13/workflow.yaml

This file was deleted.

Empty file.

0 comments on commit 41c6234

Please sign in to comment.