Security update for permissions_by_term
[yaffs-website] / vendor / drupal / drupal-extension / src / Drupal / DrupalExtension / Context / Initializer / DrupalAwareInitializer.php
1 <?php
2
3 namespace Drupal\DrupalExtension\Context\Initializer;
4
5 use Behat\Behat\Context\Initializer\ContextInitializer;
6 use Behat\Behat\Context\Context;
7 use Behat\Testwork\Hook\HookDispatcher;
8
9 use Drupal\DrupalDriverManager;
10 use Drupal\DrupalExtension\Context\DrupalContext;
11 use Drupal\DrupalExtension\Context\DrupalAwareInterface;
12
13 class DrupalAwareInitializer implements ContextInitializer {
14   private $drupal, $parameters, $dispatcher;
15
16   public function __construct(DrupalDriverManager $drupal, array $parameters, HookDispatcher $dispatcher) {
17     $this->drupal = $drupal;
18     $this->parameters = $parameters;
19     $this->dispatcher = $dispatcher;
20   }
21
22   /**
23    * {@inheritdocs}
24    */
25   public function initializeContext(Context $context) {
26
27     // All contexts are passed here, only DrupalAwareInterface is allowed.
28     if (!$context instanceof DrupalAwareInterface) {
29       return;
30     }
31
32     // Set Drupal driver manager.
33     $context->setDrupal($this->drupal);
34
35     // Set event dispatcher.
36     $context->setDispatcher($this->dispatcher);
37
38     // Add all parameters to the context.
39     $context->setDrupalParameters($this->parameters);
40   }
41
42 }