You are here

public function ProfileTypeListBuilder::getOperations in Profile 8

Provides an array of information to build a list of operation links.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity the operations are for.

Return value

array An associative array of operation link data for this list, keyed by operation name, containing the following key-value pairs:

  • title: The localized title of the operation.
  • url: An instance of \Drupal\Core\Url for the operation URL.
  • weight: The weight of this operation.

Overrides EntityListBuilder::getOperations

File

src/ProfileTypeListBuilder.php, line 37

Class

ProfileTypeListBuilder
Defines the list builder for profile types.

Namespace

Drupal\profile

Code

public function getOperations(EntityInterface $entity) {
  $operations = parent::getOperations($entity);

  // Place the edit operation after the operations added by field_ui.module
  // which have the weights 15, 20, 25.
  if (isset($operations['edit'])) {
    $operations['edit'] = [
      'title' => $this
        ->t('Edit'),
      'weight' => 30,
      'url' => $entity
        ->toUrl('edit-form'),
    ];
  }
  if (isset($operations['delete'])) {
    $operations['delete'] = [
      'title' => $this
        ->t('Delete'),
      'weight' => 35,
      'url' => $entity
        ->toUrl('delete-form'),
    ];
  }

  // Sort the operations to normalize link order.
  uasort($operations, [
    'Drupal\\Component\\Utility\\SortArray',
    'sortByWeightElement',
  ]);
  return $operations;
}