You are here

protected function PasswordPolicyConstraintForm::getOperations in Password Policy 8.3

Helper function to load edit operations for a constraint.

Parameters

string $route_name_base: String representing the base of the route name for the constraints.

array $route_parameters: Passing route parameter context to the helper function.

Return value

array Set of operations associated with a constraint.

1 call to PasswordPolicyConstraintForm::getOperations()
PasswordPolicyConstraintForm::renderRows in src/Form/PasswordPolicyConstraintForm.php
Helper function to render the constraint rows for the policy.

File

src/Form/PasswordPolicyConstraintForm.php, line 205

Class

PasswordPolicyConstraintForm
Form that lists out the constraints for the policy.

Namespace

Drupal\password_policy\Form

Code

protected function getOperations($route_name_base, array $route_parameters = []) {
  $edit_url = new Url($route_name_base . '.edit', $route_parameters);
  $route_parameters['id'] = $route_parameters['constraint_id'];
  unset($route_parameters['constraint_id']);
  $delete_url = new Url($route_name_base . '.delete', $route_parameters);
  $operations = [];
  $operations['edit'] = [
    'title' => $this
      ->t('Edit'),
    'url' => $edit_url,
    'weight' => 10,
    'attributes' => [
      'class' => [
        'use-ajax',
      ],
      'data-dialog-type' => 'modal',
      'data-dialog-options' => Json::encode([
        'width' => 700,
      ]),
    ],
  ];
  $operations['delete'] = [
    'title' => $this
      ->t('Delete'),
    'url' => $delete_url,
    'weight' => 100,
    'attributes' => [
      'class' => [
        'use-ajax',
      ],
      'data-dialog-type' => 'modal',
      'data-dialog-options' => Json::encode([
        'width' => 700,
      ]),
    ],
  ];
  return $operations;
}