function FieldConfigListBuilder::getDefaultOperations

Same name in other branches
  1. 8.9.x core/modules/field_ui/src/FieldConfigListBuilder.php \Drupal\field_ui\FieldConfigListBuilder::getDefaultOperations()
  2. 10 core/modules/field_ui/src/FieldConfigListBuilder.php \Drupal\field_ui\FieldConfigListBuilder::getDefaultOperations()
  3. 11.x core/modules/field_ui/src/FieldConfigListBuilder.php \Drupal\field_ui\FieldConfigListBuilder::getDefaultOperations()

Overrides ConfigEntityListBuilder::getDefaultOperations

File

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

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.