You are here

public function ImportEntityListBuilder::getOperations in Content Synchronizer 8.2

Same name and namespace in other branches
  1. 3.x src/ImportEntityListBuilder.php \Drupal\content_synchronizer\ImportEntityListBuilder::getOperations()

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/ImportEntityListBuilder.php, line 48

Class

ImportEntityListBuilder
Defines a class to build a listing of Import entities.

Namespace

Drupal\content_synchronizer

Code

public function getOperations(EntityInterface $entity) {
  $operations = parent::getOperations($entity);
  $operations['view'] = [
    'title' => t('Import'),
    'weight' => 1,
    'url' => new Url('entity.import_entity.canonical', [
      'import_entity' => $entity
        ->id(),
    ]),
  ];
  usort($operations, function ($a, $b) {
    if ($a['weight'] > $b['weight']) {
      return 1;
    }
    return -1;
  });
  return $operations;
}