Skip to content

Commit 68ec7b7

Browse files
loic425GSadee
authored andcommitted
Move fos rest, jms serializer and hateoas on dev requirements
1 parent 9aeddfe commit 68ec7b7

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Sylius package.
5+
*
6+
* (c) Sylius Sp. z o.o.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler;
15+
16+
use FOS\RestBundle\FOSRestBundle;
17+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18+
use Symfony\Component\DependencyInjection\ContainerBuilder;
19+
20+
final class FosRestPass implements CompilerPassInterface
21+
{
22+
public function process(ContainerBuilder $container): void
23+
{
24+
/** @var array $bundles */
25+
$bundles = $container->getParameter('kernel.bundles');
26+
27+
if (in_array(FOSRestBundle::class, $bundles, true)) {
28+
return;
29+
}
30+
31+
$container->removeDefinition('sylius.resource_controller.view_handler');
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Sylius package.
5+
*
6+
* (c) Sylius Sp. z o.o.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler;
15+
16+
use Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle;
17+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18+
use Symfony\Component\DependencyInjection\ContainerBuilder;
19+
20+
final class HateoasPass implements CompilerPassInterface
21+
{
22+
public function process(ContainerBuilder $container): void
23+
{
24+
/** @var array $bundles */
25+
$bundles = $container->getParameter('kernel.bundles');
26+
27+
if (in_array(BazingaHateoasBundle::class, $bundles, true)) {
28+
return;
29+
}
30+
31+
$container->removeDefinition('sylius.resource_controller.pagerfanta_representation_factory');
32+
}
33+
}

src/Bundle/SyliusResourceBundle.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\CsrfTokenManagerPass;
1717
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\DoctrineContainerRepositoryFactoryPass;
1818
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\DoctrineTargetEntitiesResolverPass;
19+
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\FosRestPass;
20+
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\HateoasPass;
1921
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\Helper\TargetEntitiesResolver;
2022
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\PagerfantaBridgePass;
2123
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterFormBuilderPass;
@@ -52,6 +54,8 @@ public function build(ContainerBuilder $container): void
5254
$container->addCompilerPass(new DisableMetadataCachePass());
5355
$container->addCompilerPass(new DoctrineContainerRepositoryFactoryPass());
5456
$container->addCompilerPass(new DoctrineTargetEntitiesResolverPass(new TargetEntitiesResolver()), PassConfig::TYPE_BEFORE_OPTIMIZATION, 1);
57+
$container->addCompilerPass(new FosRestPass());
58+
$container->addCompilerPass(new HateoasPass());
5559
$container->addCompilerPass(new RegisterFormBuilderPass());
5660
$container->addCompilerPass(new RegisterFqcnControllersPass());
5761
$container->addCompilerPass(new RegisterResourceRepositoryPass());

0 commit comments

Comments
 (0)