Last active
July 19, 2020 19:56
-
-
Save vudaltsov/35fdfdf8785d5cb870c8b2d3644e1b6e to your computer and use it in GitHub Desktop.
Removing unnecessary Symfony services via a compiler pass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace Application; | |
use Application\DependencyInjection\RemoveObjectNormalizerPass; | |
use Symfony\Component\Config\Loader\LoaderInterface; | |
use Symfony\Component\DependencyInjection\Compiler\PassConfig; | |
use Symfony\Component\DependencyInjection\ContainerBuilder; | |
use Symfony\Component\HttpKernel\Kernel; | |
final class AppKernel extends Kernel | |
{ | |
// ... | |
/** | |
* {@inheritDoc} | |
*/ | |
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void | |
{ | |
// ... | |
$container->addCompilerPass(new RemoveObjectNormalizerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 200); | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace Application\DependencyInjection; | |
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | |
use Symfony\Component\DependencyInjection\ContainerBuilder; | |
final class RemoveObjectNormalizerPass implements CompilerPassInterface | |
{ | |
/** | |
* {@inheritDoc} | |
*/ | |
public function process(ContainerBuilder $container): void | |
{ | |
$container->removeDefinition('serializer.normalizer.object'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment