Created
December 6, 2019 14:47
-
-
Save alexey-kuznetsov/6890dc4bd80361f428222c89748a1c34 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // No constructor method | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { | |
| $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition); | |
| $instance->logger = $container->get('logger.factory')->get('my_logger'); | |
| $instance->currentUser = $container->get('current_user'); | |
| return $instance; | |
| } |
This file contains hidden or 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
| /** | |
| * Constructor. | |
| * | |
| * @param array $configuration | |
| * @param string $plugin_id | |
| * @param mixed $plugin_definition | |
| * @param array $serializer_formats | |
| * @param \Psr\Log\LoggerInterface $logger | |
| * @param \Drupal\Core\Session\AccountProxyInterface $current_user | |
| */ | |
| public function __construct( | |
| array $configuration, | |
| $plugin_id, | |
| $plugin_definition, | |
| array $serializer_formats, | |
| LoggerInterface $logger, | |
| AccountProxyInterface $current_user | |
| ) { | |
| parent::__construct($configuration, $plugin_id, $plugin_definition, $serializer_formats, $logger); | |
| $this->currentUser = $current_user; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { | |
| return new static( | |
| $configuration, | |
| $plugin_id, | |
| $plugin_definition, | |
| $container->getParameter('serializer.formats'), | |
| $container->get('logger.factory')->get('my_logger'), | |
| $container->get('current_user') | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment