| @@ 9-22 (lines=14) @@ | ||
| 6 | use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
| 7 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
| 8 | ||
| 9 | class AddReadOnlyHydrationModePass implements CompilerPassInterface |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * @param ContainerBuilder $container |
|
| 13 | */ |
|
| 14 | public function process(ContainerBuilder $container) |
|
| 15 | { |
|
| 16 | $hydrator = [ReadOnlyHydrator::HYDRATOR_NAME, ReadOnlyHydrator::class]; |
|
| 17 | foreach ($container->getParameter('doctrine.entity_managers') as $name => $serviceName) { |
|
| 18 | $definition = $container->getDefinition('doctrine.orm.' . $name . '_configuration'); |
|
| 19 | $definition->addMethodCall('addCustomHydrationMode', $hydrator); |
|
| 20 | } |
|
| 21 | } |
|
| 22 | } |
|
| 23 | ||
| @@ 9-22 (lines=14) @@ | ||
| 6 | use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
| 7 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
| 8 | ||
| 9 | class AddSimpleObjectHydrationModePass implements CompilerPassInterface |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * @param ContainerBuilder $container |
|
| 13 | */ |
|
| 14 | public function process(ContainerBuilder $container) |
|
| 15 | { |
|
| 16 | $hydrator = [SimpleObjectHydrator::HYDRATOR_NAME, SimpleObjectHydrator::class]; |
|
| 17 | foreach ($container->getParameter('doctrine.entity_managers') as $name => $serviceName) { |
|
| 18 | $definition = $container->getDefinition('doctrine.orm.' . $name . '_configuration'); |
|
| 19 | $definition->addMethodCall('addCustomHydrationMode', $hydrator); |
|
| 20 | } |
|
| 21 | } |
|
| 22 | } |
|
| 23 | ||