Skip to content

Sylius 2.x compatibility #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 9 additions & 30 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4" # Always use the lowest version of PHP since a higher version could create actual syntax errors in lower versions
- "8.2" # Always use the lowest version of PHP since a higher version could create actual syntax errors in lower versions

dependencies:
- "highest"
Expand Down Expand Up @@ -67,9 +67,6 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"

Expand All @@ -78,12 +75,8 @@ jobs:
- "highest"

symfony:
- "^5.4"
- "^6.0"

exclude:
- php-version: "7.4"
symfony: "^6.0"
- "^6.4"
- "^7.1"

steps:
- name: "Checkout"
Expand Down Expand Up @@ -121,9 +114,6 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"

Expand All @@ -132,12 +122,8 @@ jobs:
- "highest"

symfony:
- "^5.4"
- "^6.0"

exclude:
- php-version: "7.4"
symfony: "^6.0"
- "^6.4"
- "^7.1"

steps:
- name: "Checkout"
Expand Down Expand Up @@ -172,22 +158,15 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"

dependencies:
- "highest"

symfony:
- "^5.4"
- "^6.0"

exclude:
- php-version: "7.4"
symfony: "^6.0"
- "^6.4"
- "^7.1"

steps:
- name: "Checkout"
Expand Down Expand Up @@ -225,7 +204,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.2"

dependencies:
- "highest"
Expand All @@ -247,7 +226,7 @@ jobs:
- name: "Setup node"
uses: "actions/setup-node@v3"
with:
node-version: "16"
node-version: "20"

- name: "Install composer dependencies"
uses: "ramsey/composer-install@v3"
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,7 @@ $ bin/console doctrine:migrations:diff
$ bin/console doctrine:migrations:migrate
```

### Step 5: Copy template

You can copy the templates under `tests/Application/templates/bundles/SyliusAdminBundle` into your own application to enable the possibility to add an automatic redirection when updating product

### Step 6: Install assets
### Step 5: Install assets
```bash
$ bin/console assets:install
```
Expand Down
69 changes: 41 additions & 28 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,61 @@
"sylius-plugin"
],
"require": {
"php": ">=7.4",
"doctrine/collections": "^1.6",
"php": ">=8.2",
"doctrine/collections": "^2.2",
"doctrine/orm": "^2.7",
"doctrine/persistence": "^1.3 || ^2.1 || ^3.0",
"league/uri": "^6.0 || ^7.5",
"league/uri-components": "^2.3 || ^7.5",
"psr/log": "^1.1 || ^2.0 || ^3.0",
"sylius/channel": "^1.0",
"sylius/channel-bundle": "^1.0",
"sylius/core-bundle": "^1.0",
"sylius/product-bundle": "^1.0",
"sylius/resource-bundle": "^1.6",
"sylius/taxonomy-bundle": "^1.0",
"sylius/ui-bundle": "^1.0",
"symfony/config": "^5.4 || ^6.0",
"symfony/console": "^5.4 || ^6.0",
"symfony/dependency-injection": "^5.4 || ^6.0",
"symfony/event-dispatcher": "^5.4 || ^6.0",
"symfony/form": "^5.4 || ^6.0",
"symfony/http-foundation": "^5.4 || ^6.0",
"symfony/http-kernel": "^5.4 || ^6.0",
"symfony/routing": "^5.4 || ^6.0",
"symfony/validator": "^5.4 || ^6.0",
"sylius/admin-bundle": "^2.0",
"sylius/channel": "^2.0",
"sylius/channel-bundle": "^2.0",
"sylius/core-bundle": "^2.0",
"sylius/product-bundle": "^2.0",
"sylius/resource-bundle": "^1.12",
"sylius/taxonomy-bundle": "^2.0",
"sylius/ui-bundle": "^2.0",
"symfony/config": "^6.4 || ^7.1",
"symfony/console": "^6.4 || ^7.1",
"symfony/dependency-injection": "^6.4 || ^7.1",
"symfony/event-dispatcher": "^6.4 || ^7.1",
"symfony/form": "^6.4 || ^7.1",
"symfony/http-foundation": "^6.4 || ^7.1",
"symfony/http-kernel": "^6.4 || ^7.1",
"symfony/routing": "^6.4 || ^7.1",
"symfony/ux-twig-component": "^2.20",
"symfony/validator": "^6.4 || ^7.1",
"webmozart/assert": "^1.11"
},
"require-dev": {
"api-platform/core": "^2.7",
"lexik/jwt-authentication-bundle": "^2.16",
"api-platform/core": "^4.0.3",
"behat/behat": "^3.14",
"behat/mink-selenium2-driver": "1.6.0",
"dmore/behat-chrome-extension": "^1.4",
"dmore/chrome-mink-driver": "^2.9",
"friends-of-behat/mink": "^1.11",
"friends-of-behat/mink-browserkit-driver": "^1.6",
"friends-of-behat/mink-debug-extension": "^2.1",
"friends-of-behat/mink-extension": "^2.7",
"friends-of-behat/page-object-extension": "^0.3",
"friends-of-behat/suite-settings-extension": "^1.1",
"friends-of-behat/symfony-extension": "^2.6",
"friends-of-behat/variadic-extension": "^1.6",
"lexik/jwt-authentication-bundle": "^3.1",
"php-http/message-factory": "^1.1",
"phpspec/phpspec": "^7.3",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.6",
"psalm/plugin-phpunit": "^0.18",
"psalm/plugin-symfony": "^5.0",
"setono/code-quality-pack": "^2.9",
"setono/sylius-behat-pack": "^0.2",
"shipmonk/composer-dependency-analyser": "^1.8",
"sylius/sylius": "~1.10.14",
"symfony/debug-bundle": "^5.4 || ^6.0",
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/intl": "^5.4 || ^6.0",
"symfony/web-profiler-bundle": "^5.4 || ^6.0",
"symfony/webpack-encore-bundle": "^1.16"
"sylius/sylius": "~2.0.0",
"symfony/debug-bundle": "^6.4 || ^7.1",
"symfony/dotenv": "^6.4 || ^7.1",
"symfony/intl": "^6.4 || ^7.1",
"symfony/web-profiler-bundle": "^6.4 || ^7.1",
"symfony/webpack-encore-bundle": "^2.2"
},
"prefer-stable": true,
"autoload": {
Expand All @@ -73,6 +85,7 @@
"dealerdirect/phpcodesniffer-composer-installer": false,
"ergebnis/composer-normalize": true,
"ocramius/package-versions": true,
"php-http/discovery": true,
"symfony/thanks": false
},
"sort-packages": true
Expand Down
21 changes: 12 additions & 9 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@

declare(strict_types=1);

use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import('vendor/sylius-labs/coding-standard/ecs.php');
$containerConfigurator->parameters()->set(Option::PATHS, [
'src', 'tests'
return static function (ECSConfig $ecsConfig): void {
$ecsConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests/',
__DIR__ . '/ecs.php',
]);
$containerConfigurator->parameters()->set(Option::SKIP, [
'tests/Application/**',

$ecsConfig->import('vendor/sylius-labs/coding-standard/ecs.php');

$ecsConfig->skip([
VisibilityRequiredFixer::class => ['*Spec.php'],
]);
};
3 changes: 3 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.14.1@b9d355e0829c397b9b3b47d0c0ed042a8a70284d">
</files>
1 change: 0 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
</ignoreFiles>
</projectFiles>
<plugins>
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
<forbiddenFunctions>
Expand Down
6 changes: 2 additions & 4 deletions src/Command/RemoveRedirectsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
namespace Setono\SyliusRedirectPlugin\Command;

use Setono\SyliusRedirectPlugin\Repository\RedirectRepositoryInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(name: 'setono:sylius-redirect:remove', description: 'This command will remove redirects that have not been accessed later than x days ago where x is the `setono_sylius_redirect.remove_after` parameter')]
class RemoveRedirectsCommand extends Command
{
protected static $defaultName = 'setono:sylius-redirect:remove';

protected static $defaultDescription = 'This command will remove redirects that have not been accessed later than x days ago where x is the `setono_sylius_redirect.remove_after` parameter';

private RedirectRepositoryInterface $redirectRepository;

private int $removeAfter;
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/ControllerSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class ControllerSubscriber implements EventSubscriberInterface, LoggerAwar
public function __construct(
ObjectManager $objectManager,
ChannelContextInterface $channelContext,
RedirectionPathResolverInterface $redirectionPathResolver
RedirectionPathResolverInterface $redirectionPathResolver,
) {
$this->logger = new NullLogger();
$this->objectManager = $objectManager;
Expand All @@ -57,7 +57,7 @@ public function onKernelController(ControllerEvent $event): void
}
$redirectionPath = $this->redirectionPathResolver->resolveFromRequest(
$request,
$channel
$channel,
);

if ($redirectionPath->isEmpty()) {
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/NotFoundSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class NotFoundSubscriber implements EventSubscriberInterface, LoggerAwareInterfa
public function __construct(
ObjectManager $objectManager,
ChannelContextInterface $channelContext,
RedirectionPathResolverInterface $redirectionPathResolver
RedirectionPathResolverInterface $redirectionPathResolver,
) {
$this->logger = new NullLogger();
$this->objectManager = $objectManager;
Expand Down Expand Up @@ -69,7 +69,7 @@ public function onKernelException(ExceptionEvent $event): void
$redirectionPath = $this->redirectionPathResolver->resolveFromRequest(
$request,
$channel,
true
true,
);

if ($redirectionPath->isEmpty()) {
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/RedirectResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static function getRedirectResponse(RedirectInterface $lastRedirect, stri

return new RedirectResponse(
$uri->__toString(),
$lastRedirect->isPermanent() ? Response::HTTP_MOVED_PERMANENTLY : Response::HTTP_FOUND
$lastRedirect->isPermanent() ? Response::HTTP_MOVED_PERMANENTLY : Response::HTTP_FOUND,
);
}
}
2 changes: 1 addition & 1 deletion src/Factory/RedirectFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function createNewWithValues(
string $destination,
bool $permanent = true,
bool $only404 = true,
iterable $channels = []
iterable $channels = [],
): RedirectInterface {
$redirect = $this->createNew();

Expand Down
2 changes: 1 addition & 1 deletion src/Factory/RedirectFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public function createNewWithValues(
string $destination,
bool $permanent = true,
bool $only404 = true,
iterable $channels = []
iterable $channels = [],
): RedirectInterface;
}
1 change: 0 additions & 1 deletion src/Model/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
class Redirect implements RedirectInterface
{
use TimestampableTrait;

use ToggleableTrait;

protected ?int $id = null;
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/RedirectRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function removeNotAccessed(int $threshold): void
->delete()
->orWhere(
'r.lastAccessed is not null and r.lastAccessed <= :threshold',
'r.lastAccessed is null and r.createdAt <= :threshold'
'r.lastAccessed is null and r.createdAt <= :threshold',
)
->setParameter('threshold', $dateTimeThreshold)
->getQuery()
Expand Down
6 changes: 3 additions & 3 deletions src/Resolver/RedirectionPathResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(RedirectRepositoryInterface $redirectRepository)
public function resolve(
string $source,
ChannelInterface $channel = null,
bool $only404 = false
bool $only404 = false,
): RedirectionPath {
$redirectionPath = new RedirectionPath();

Expand All @@ -39,7 +39,7 @@ public function resolve(
$firstRedirect = $redirectionPath->first();

throw new InfiniteLoopException(
null !== $firstRedirect ? ($firstRedirect->getSource() ?? $source) : $source
null !== $firstRedirect ? ($firstRedirect->getSource() ?? $source) : $source,
);
}
} while (null !== $redirect && !$redirect->isOnly404()); // See this issue for explanation of this: https://github.com/Setono/SyliusRedirectPlugin/issues/27
Expand All @@ -50,7 +50,7 @@ public function resolve(
public function resolveFromRequest(
Request $request,
ChannelInterface $channel = null,
bool $only404 = false
bool $only404 = false,
): RedirectionPath {
return $this->resolve($request->getPathInfo(), $channel, $only404);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Resolver/RedirectionPathResolverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public function resolve(string $source, ChannelInterface $channel = null, bool $
public function resolveFromRequest(
Request $request,
ChannelInterface $channel = null,
bool $only404 = false
bool $only404 = false,
): RedirectionPath;
}
Loading