function FieldConfigListBuilder::getDefaultOperations

Same name in other branches
  1. 9 core/modules/field_ui/src/FieldConfigListBuilder.php \Drupal\field_ui\FieldConfigListBuilder::getDefaultOperations()
  2. 8.9.x 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 177

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.'),
                'class' => [
                    'use-ajax',
                ],
                'data-dialog-type' => 'modal',
                'data-dialog-options' => Json::encode([
                    'width' => 880,
                ]),
            ],
        ];
    }
    return $operations;
}

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