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 757b698
Show file tree
Hide file tree
Showing 11 changed files with 27 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
7 changes: 7 additions & 0 deletions UPGRADE-1.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@
constructors of `Sylius\RefundPlugin\Converter\LineItem\OrderItemUnitLineItemsConverter` and
`Sylius\RefundPlugin\Converter\LineItem\ShipmentLineItemsConverter`
has been deprecated and will be prohibited in 2.0.

5. Support for Sylius 1.13 has been added, it is now the recommended Sylius version to use with RefundPlugin.

6. Support for Sylius 1.11 has been dropped, upgrade your application to [Sylius 1.12](https://github.com/Sylius/Sylius/blob/1.12/UPGRADE-1.12.md).
or to [Sylius 1.13](https://github.com/Sylius/Sylius/blob/1.13/UPGRADE-1.13.md).

7. Support for PHP 8.0 has been dropped.
13 changes: 13 additions & 0 deletions src/DependencyInjection/SyliusRefundExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;

final class SyliusRefundExtension extends Extension implements PrependExtensionInterface
{
Expand Down Expand Up @@ -58,6 +59,7 @@ public function prepend(ContainerBuilder $container): void
$container->setParameter('sylius_refund.pdf_generator.enabled', $configs['pdf_generator']['enabled']);

$this->prependDoctrineMigrations($container);
$this->prependSymfonyWorkflow($container);
}

protected function getMigrationsNamespace(): string
Expand Down Expand Up @@ -94,4 +96,15 @@ private function tagsAutoconfiguration(ContainerBuilder $container, array $tagge
$container->registerForAutoconfiguration($interface)->addTag($tag);
}
}

private function prependSymfonyWorkflow(ContainerBuilder $container): void
{
if (!class_exists('\Symfony\Component\Workflow\Workflow')) {
return;
}

$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));

$loader->load('integrations/workflow.yaml');
}
}
File renamed without changes.
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.

1 change: 0 additions & 1 deletion tests/Application/config/sylius/1.13/_sylius.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ parameters:
test_default_state_machine_adapter: 'symfony_workflow'
test_sylius_state_machine_adapter: '%env(string:default:test_default_state_machine_adapter:TEST_SYLIUS_STATE_MACHINE_ADAPTER)%'


sylius_state_machine_abstraction:
graphs_to_adapters_mapping:
sylius_refund_refund_payment: '%test_sylius_state_machine_adapter%'
21 changes: 0 additions & 21 deletions tests/Application/config/sylius/1.13/workflow.yaml

This file was deleted.

Empty file.

0 comments on commit 757b698

Please sign in to comment.