Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / PluginBase.php
1 <?php
2
3 namespace Drupal\drupalmoduleupgrader;
4
5 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
6 use Drupal\Core\Plugin\PluginBase as CorePluginBase;
7 use Drupal\Core\StringTranslation\TranslationInterface;
8 use Psr\Log\LoggerInterface;
9 use Symfony\Component\DependencyInjection\ContainerInterface;
10
11 /**
12  * Base class for all DMU plugin types, pulling string translation and logging
13  * services from the container by default.
14  *
15  * @deprecated
16  */
17 abstract class PluginBase extends CorePluginBase implements ContainerFactoryPluginInterface {
18
19   /**
20    * @var LoggerInterface
21    */
22   protected $log;
23
24   public function __construct(array $configuration, $plugin_id, $plugin_definition, TranslationInterface $translator, LoggerInterface $log) {
25     parent::__construct($configuration, $plugin_id, $plugin_definition);
26     $this->stringTranslation = $translator;
27     $this->log = $log;
28   }
29
30   /**
31    * {@inheritdoc}
32    */
33   public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
34     $arguments = [
35       $configuration,
36       $plugin_id,
37       $plugin_definition,
38       // Always include the string translation and logging services.
39       $container->get('string_translation'),
40       $container->get('logger.factory')->get('drupalmoduleupgrader'),
41     ];
42
43     // Pull any declared dependencies out of the container.
44     if (isset($plugin_definition['dependencies'])) {
45       foreach ($plugin_definition['dependencies'] as $dependency) {
46         $arguments[] = $container->get($dependency);
47       }
48     }
49
50     return (new \ReflectionClass(get_called_class()))->newInstanceArgs($arguments);
51   }
52
53 }