You are here

public function FlexiformFormEntityBase::__construct in Flexiform 8

Overrides \Drupal\Component\Plugin\PluginBase::__construct().

Overrides the construction of context aware plugins to allow for unvalidated constructor based injection of contexts.

Parameters

array $configuration: The plugin configuration, i.e. an array with configuration values keyed by configuration option name. The special key 'context' may be used to initialize the defined contexts by setting it to an array of context values keyed by context names.

string $plugin_id: The plugin_id for the plugin instance.

mixed $plugin_definition: The plugin implementation definition.

Overrides ContextAwarePluginBase::__construct

3 calls to FlexiformFormEntityBase::__construct()
FlexiformFormEntityProvided::__construct in src/Plugin/FlexiformFormEntity/FlexiformFormEntityProvided.php
Overrides \Drupal\Component\Plugin\PluginBase::__construct().
FlexiformFormEntityTypedDataReferencedEntity::__construct in src/Plugin/FlexiformFormEntity/FlexiformFormEntityTypedDataReferencedEntity.php
Overrides \Drupal\Component\Plugin\PluginBase::__construct().
UserProfile::__construct in src/Plugin/FlexiformFormEntity/UserProfile.php
Overrides \Drupal\Component\Plugin\PluginBase::__construct().
3 methods override FlexiformFormEntityBase::__construct()
FlexiformFormEntityProvided::__construct in src/Plugin/FlexiformFormEntity/FlexiformFormEntityProvided.php
Overrides \Drupal\Component\Plugin\PluginBase::__construct().
FlexiformFormEntityTypedDataReferencedEntity::__construct in src/Plugin/FlexiformFormEntity/FlexiformFormEntityTypedDataReferencedEntity.php
Overrides \Drupal\Component\Plugin\PluginBase::__construct().
UserProfile::__construct in src/Plugin/FlexiformFormEntity/UserProfile.php
Overrides \Drupal\Component\Plugin\PluginBase::__construct().

File

src/FormEntity/FlexiformFormEntityBase.php, line 40

Class

FlexiformFormEntityBase
Provides the base form entity plugin.

Namespace

Drupal\flexiform\FormEntity

Code

public function __construct(array $configuration, $plugin_id, $plugin_definition) {
  if (!isset($configuration['manager'])) {
    throw new \Exception('No Form Entity Manager Supplied');
  }

  // Set the form entity manager.
  $this->formEntityManager = $configuration['manager'];

  // Unset these values so they can't be accessed like normal configuration.
  unset($configuration['manager']);
  unset($configuration['namespace']);
  parent::__construct($configuration, $plugin_id, $plugin_definition);

  // Load in the required contexts for this plugin.
  if (!empty($configuration['context_mapping'])) {
    foreach ($configuration['context_mapping'] as $key => $context_namespace) {
      $context = $this->formEntityManager
        ->getContext($context_namespace);
      $this->context[$key] = $context;
    }
  }
}