Skip to content

Commit

Permalink
Move fos rest, jms serializer and hateoas on dev requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 authored and GSadee committed Oct 7, 2024
1 parent 9aeddfe commit 68ec7b7
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/Bundle/DependencyInjection/Compiler/FosRestPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler;

use FOS\RestBundle\FOSRestBundle;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

final class FosRestPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
/** @var array $bundles */
$bundles = $container->getParameter('kernel.bundles');

if (in_array(FOSRestBundle::class, $bundles, true)) {
return;
}

$container->removeDefinition('sylius.resource_controller.view_handler');
}
}
33 changes: 33 additions & 0 deletions src/Bundle/DependencyInjection/Compiler/HateoasPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler;

use Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

final class HateoasPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
/** @var array $bundles */
$bundles = $container->getParameter('kernel.bundles');

if (in_array(BazingaHateoasBundle::class, $bundles, true)) {
return;
}

$container->removeDefinition('sylius.resource_controller.pagerfanta_representation_factory');
}
}
4 changes: 4 additions & 0 deletions src/Bundle/SyliusResourceBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\CsrfTokenManagerPass;
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\DoctrineContainerRepositoryFactoryPass;
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\DoctrineTargetEntitiesResolverPass;
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\FosRestPass;
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\HateoasPass;
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\Helper\TargetEntitiesResolver;
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\PagerfantaBridgePass;
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterFormBuilderPass;
Expand Down Expand Up @@ -52,6 +54,8 @@ public function build(ContainerBuilder $container): void
$container->addCompilerPass(new DisableMetadataCachePass());
$container->addCompilerPass(new DoctrineContainerRepositoryFactoryPass());
$container->addCompilerPass(new DoctrineTargetEntitiesResolverPass(new TargetEntitiesResolver()), PassConfig::TYPE_BEFORE_OPTIMIZATION, 1);
$container->addCompilerPass(new FosRestPass());
$container->addCompilerPass(new HateoasPass());
$container->addCompilerPass(new RegisterFormBuilderPass());
$container->addCompilerPass(new RegisterFqcnControllersPass());
$container->addCompilerPass(new RegisterResourceRepositoryPass());
Expand Down

0 comments on commit 68ec7b7

Please sign in to comment.