You are here

public function FieldConfigListBuilder::getDefaultOperations in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/field_ui/src/FieldConfigListBuilder.php \Drupal\field_ui\FieldConfigListBuilder::getDefaultOperations()

Gets this list's default operations.

Parameters

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

Return value

array The array structure is identical to the return value of self::getOperations().

Overrides ConfigEntityListBuilder::getDefaultOperations

File

core/modules/field_ui/src/FieldConfigListBuilder.php, line 184

Class

FieldConfigListBuilder
Provides lists of field config entities.

Namespace

Drupal\field_ui

Code

public function getDefaultOperations(EntityInterface $entity) {

  /** @var \Drupal\field\FieldConfigInterface $entity */
  $operations = parent::getDefaultOperations($entity);
  if ($entity
    ->access('update') && $entity
    ->hasLinkTemplate("{$entity->getTargetEntityTypeId()}-field-edit-form")) {
    $operations['edit'] = [
      'title' => $this
        ->t('Edit'),
      'weight' => 10,
      'url' => $entity
        ->toUrl("{$entity->getTargetEntityTypeId()}-field-edit-form"),
      'attributes' => [
        'title' => $this
          ->t('Edit field settings.'),
      ],
    ];
  }
  if ($entity
    ->access('delete') && $entity
    ->hasLinkTemplate("{$entity->getTargetEntityTypeId()}-field-delete-form")) {
    $operations['delete'] = [
      'title' => $this
        ->t('Delete'),
      'weight' => 100,
      'url' => $entity
        ->toUrl("{$entity->getTargetEntityTypeId()}-field-delete-form"),
      'attributes' => [
        'title' => $this
          ->t('Delete field.'),
      ],
    ];
  }
  $operations['storage-settings'] = [
    'title' => $this
      ->t('Storage settings'),
    'weight' => 20,
    'attributes' => [
      'title' => $this
        ->t('Edit storage settings.'),
    ],
    'url' => $entity
      ->toUrl("{$entity->getTargetEntityTypeId()}-storage-edit-form"),
  ];
  return $operations;
}