-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/1.2'
- Loading branch information
Showing
29 changed files
with
1,323 additions
and
113 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
42 changes: 42 additions & 0 deletions
42
...PublishCoreBundle/DependencyInjection/Compiler/EntityManagerFactoryServiceLocatorPass.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
final class EntityManagerFactoryServiceLocatorPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container): void | ||
{ | ||
$entityManagerFactory = $container->getDefinition('ibexa.doctrine.orm.entity_manager_factory'); | ||
|
||
$ibexaEntityManagers = $this->getIbexaEntityManagers($container); | ||
$entityManagerFactory->setArgument( | ||
'$serviceLocator', | ||
ServiceLocatorTagPass::register($container, $ibexaEntityManagers) | ||
); | ||
} | ||
|
||
private function getIbexaEntityManagers(ContainerBuilder $container): array | ||
{ | ||
$entityManagers = []; | ||
foreach ($container->getParameter('doctrine.entity_managers') as $name => $serviceId) { | ||
if (false === strpos($name, 'ibexa_')) { | ||
continue; | ||
} | ||
|
||
$entityManagers[$serviceId] = new Reference($serviceId); | ||
} | ||
|
||
return $entityManagers; | ||
} | ||
} |
Oops, something went wrong.