You are here

public function EntityReferenceActionsHandler::init in Entity reference actions 1.x

Initialize the form.

Parameters

string $entity_type_id: Entity type of this field.

mixed[] $settings: Third party settings.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

File

src/EntityReferenceActionsHandler.php, line 135

Class

EntityReferenceActionsHandler
Provides the form functions to call actions on referenced entities.

Namespace

Drupal\entity_reference_actions

Code

public function init($entity_type_id, array $settings) {
  $this->entityTypeId = $entity_type_id;
  $actionStorage = $this->entityTypeManager
    ->getStorage('action');
  $this->actions = array_filter($actionStorage
    ->loadMultiple(), function ($action) {
    return $action
      ->getType() == $this->entityTypeId;
  });
  $this->settings = NestedArray::mergeDeepArray([
    [
      'enabled' => FALSE,
      'options' => [
        'action_title' => $this
          ->t('Action'),
        'include_exclude' => 'exclude',
        'selected_actions' => [],
      ],
    ],
    $settings,
  ]);
}