You are here

public function WebformNodeReferencesListController::__construct in Webform 8.5

Constructs a new WebformNodeReferencesListController object.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition.

\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage class.

\Drupal\Core\Datetime\DateFormatterInterface $date_formatter: The date formatter service.

\Drupal\Core\Config\Entity\ConfigEntityStorageInterface $node_type_storage: The node type storage class.

\Drupal\Core\Config\Entity\ConfigEntityStorageInterface $field_config_storage: The field config storage class.

\Drupal\webform\WebformSubmissionStorageInterface $webform_submission_storage: The webform submission storage class.

\Drupal\webform\WebformEntityReferenceManagerInterface $webform_entity_reference_manager: The webform entity reference manager.

Overrides EntityListBuilder::__construct

File

modules/webform_node/src/Controller/WebformNodeReferencesListController.php, line 124

Class

WebformNodeReferencesListController
Defines a controller for webform node references.

Namespace

Drupal\webform_node\Controller

Code

public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, DateFormatterInterface $date_formatter, ConfigEntityStorageInterface $node_type_storage, ConfigEntityStorageInterface $field_config_storage, WebformSubmissionStorageInterface $webform_submission_storage, WebformEntityReferenceManagerInterface $webform_entity_reference_manager) {
  parent::__construct($entity_type, $storage);
  $this->dateFormatter = $date_formatter;
  $this->nodeTypeStorage = $node_type_storage;
  $this->fieldConfigStorage = $field_config_storage;
  $this->submissionStorage = $webform_submission_storage;
  $this->webformEntityReferenceManager = $webform_entity_reference_manager;
  $this->nodeTypes = [];
  $this->fieldNames = [];

  /** @var \Drupal\node\Entity\NodeType[] $node_types */
  $node_types = $this->nodeTypeStorage
    ->loadMultiple();

  /** @var \Drupal\field\FieldConfigInterface[] $field_configs */
  $field_configs = $this->fieldConfigStorage
    ->loadByProperties([
    'entity_type' => 'node',
  ]);
  foreach ($field_configs as $field_config) {
    if ($field_config
      ->get('field_type') === 'webform') {
      $bundle = $field_config
        ->get('bundle');
      $this->nodeTypes[$bundle] = $node_types[$bundle];
      $field_name = $field_config
        ->get('field_name');
      $this->fieldNames[$field_name] = $field_name;
    }
  }
}