3 namespace Drupal\DrupalExtension\Compiler;
5 use Symfony\Component\DependencyInjection\Reference,
6 Symfony\Component\DependencyInjection\ContainerBuilder,
7 Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
10 * Drupal\DrupalExtension container compilation pass.
12 class DriverPass implements CompilerPassInterface {
14 * Register Drupal drivers.
16 public function process(ContainerBuilder $container) {
17 if (!$container->hasDefinition('drupal.drupal')) {
21 $drupalDefinition = $container->getDefinition('drupal.drupal');
22 foreach ($container->findTaggedServiceIds('drupal.driver') as $id => $attributes) {
23 foreach ($attributes as $attribute) {
24 if (isset($attribute['alias']) && $name = $attribute['alias']) {
25 $drupalDefinition->addMethodCall(
26 'registerDriver', array($name, new Reference($id))
31 // If this is Drupal Driver, then a core controller needs to be
32 // instantiated as well.
33 if ('drupal.driver.drupal' === $id) {
34 $drupalDriverDefinition = $container->getDefinition($id);
35 $availableCores = array();
36 foreach ($container->findTaggedServiceIds('drupal.core') as $coreId => $coreAttributes) {
37 foreach ($coreAttributes as $attribute) {
38 if (isset($attribute['alias']) && $name = $attribute['alias']) {
39 $availableCores[$name] = $container->getDefinition($coreId);
43 $drupalDriverDefinition->addMethodCall(
44 'setCore', array($availableCores)
49 $drupalDefinition->addMethodCall(
50 'setDefaultDriverName', array($container->getParameter('drupal.drupal.default_driver'))