-
Notifications
You must be signed in to change notification settings - Fork 691
Expand file tree
/
Copy pathJMSHandlersPass.php
More file actions
46 lines (39 loc) · 1.62 KB
/
JMSHandlersPass.php
File metadata and controls
46 lines (39 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/*
* This file is part of the FOSRestBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FOS\RestBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* Checks if the JMS serializer is available to be able to use handlers.
*
* @author Christian Flothmann <christian.flothmann@xabbuh.de>
*
* @internal
*/
final class JMSHandlersPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if ($container->has('jms_serializer.handler_registry')) {
// perform the aliasing only when jms-serializer-bundle < 4.0
if (!$container->has('jms_serializer.handler_registry.service_locator')) {
// the public alias prevents the handler registry definition from being removed
$container->setAlias('fos_rest.serializer.jms_handler_registry', new Alias('jms_serializer.handler_registry', true));
}
return;
}
if ($container->hasDefinition('fos_rest.serializer.exception_normalizer.jms')) {
$container->removeDefinition('fos_rest.serializer.exception_normalizer.jms');
}
$container->removeDefinition('fos_rest.serializer.handler_registry');
$container->getParameterBag()->remove('jms_serializer.form_error_handler.class');
}
}