You are here

public function ActionAddForm::buildForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/action/src/ActionAddForm.php \Drupal\action\ActionAddForm::buildForm()

Parameters

string $action_id: The hashed version of the action ID.

Overrides ActionFormBase::buildForm

File

core/modules/action/src/ActionAddForm.php, line 58
Contains \Drupal\action\ActionAddForm.

Class

ActionAddForm
Provides a form for action add forms.

Namespace

Drupal\action

Code

public function buildForm(array $form, FormStateInterface $form_state, $action_id = NULL) {

  // In \Drupal\action\Form\ActionAdminManageForm::buildForm() the action
  // are hashed. Here we have to decrypt it to find the desired action ID.
  foreach ($this->actionManager
    ->getDefinitions() as $id => $definition) {
    $key = Crypt::hashBase64($id);
    if ($key === $action_id) {
      $this->entity
        ->setPlugin($id);

      // Derive the label and type from the action definition.
      $this->entity
        ->set('label', $definition['label']);
      $this->entity
        ->set('type', $definition['type']);
      break;
    }
  }
  return parent::buildForm($form, $form_state);
}