Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / drush / drush / src / Drupal / DrushServiceModifier.php
1 <?php
2
3 namespace Drush\Drupal;
4
5 use Drush\Log\LogLevel;
6 use Drupal\Core\DependencyInjection\ServiceModifierInterface;
7 use Drupal\Core\DependencyInjection\ContainerBuilder;
8
9 class DrushServiceModifier implements ServiceModifierInterface
10 {
11     // Holds list of command classes implementing Symfony\Console\Component\Command
12     const DRUSH_CONSOLE_SERVICES = 'drush.console.services';
13     // Holds list of command classes implemented with annotated commands
14     const DRUSH_COMMAND_SERVICES = 'drush.command.services';
15     // Holds list of command info alterer classes.
16     const DRUSH_COMMAND_INFO_ALTERER_SERVICES = 'drush.command_info_alterer.services';
17     // Holds list of classes implementing Drupal Code Generator classes
18     const DRUSH_GENERATOR_SERVICES = 'drush.generator.services';
19
20     /**
21      * @inheritdoc
22      */
23     public function alter(ContainerBuilder $container)
24     {
25         drush_log(dt("Service modifier alter."), LogLevel::DEBUG_NOTIFY);
26         // http://symfony.com/doc/2.7/components/dependency_injection/tags.html#register-the-pass-with-the-container
27         $container->register(self::DRUSH_CONSOLE_SERVICES, 'Drush\Command\ServiceCommandlist');
28         $container->addCompilerPass(new FindCommandsCompilerPass(self::DRUSH_CONSOLE_SERVICES, 'console.command'));
29         $container->register(self::DRUSH_COMMAND_SERVICES, 'Drush\Command\ServiceCommandlist');
30         $container->addCompilerPass(new FindCommandsCompilerPass(self::DRUSH_COMMAND_SERVICES, 'drush.command'));
31         $container->register(self::DRUSH_COMMAND_INFO_ALTERER_SERVICES, 'Drush\Command\ServiceCommandlist');
32         $container->addCompilerPass(new FindCommandsCompilerPass(self::DRUSH_COMMAND_INFO_ALTERER_SERVICES, 'drush.command_info_alterer'));
33         $container->register(self::DRUSH_GENERATOR_SERVICES, 'Drush\Command\ServiceCommandlist');
34         $container->addCompilerPass(new FindCommandsCompilerPass(self::DRUSH_GENERATOR_SERVICES, 'drush.generator'));
35     }
36
37     /**
38      * Checks existing service definitions for the presence of modification.
39      *
40      * @param $container_definition
41      *   Cached container definition
42      * @return bool
43      */
44     public function check($container_definition)
45     {
46         return
47             isset($container_definition['services'][self::DRUSH_CONSOLE_SERVICES]) &&
48             isset($container_definition['services'][self::DRUSH_COMMAND_SERVICES]) &&
49             isset($container_definition['services'][self::DRUSH_COMMAND_INFO_ALTERER_SERVICES]) &&
50             isset($container_definition['services'][self::DRUSH_GENERATOR_SERVICES]);
51     }
52 }