function EntityDisplayModeListBuilder::getOperations

Same name in other branches
  1. 10 core/modules/field_ui/src/EntityDisplayModeListBuilder.php \Drupal\field_ui\EntityDisplayModeListBuilder::getOperations()

Overrides EntityListBuilder::getOperations

File

core/modules/field_ui/src/EntityDisplayModeListBuilder.php, line 79

Class

EntityDisplayModeListBuilder
Defines a class to build a listing of view mode entities.

Namespace

Drupal\field_ui

Code

public function getOperations(EntityInterface $entity) {
    // Make the edit form render in a dialog, like the add form.
    // The edit form also contains an option to delete the view mode, which
    // also spawns a dialog. Rather than have nested dialogs, we allow the
    // existing dialog to be replaced, so users will be shown the list again
    // if they cancel deleting the view mode.
    $operations = parent::getOperations($entity);
    if (isset($operations['edit'])) {
        $operations['edit'] = NestedArray::mergeDeepArray([
            [
                'attributes' => [
                    'class' => [
                        'button',
                        'use-ajax',
                    ],
                    'data-dialog-type' => 'modal',
                    'data-dialog-options' => Json::encode([
                        'width' => '880',
                    ]),
                ],
            ],
            $operations['edit'],
        ]);
    }
    return $operations;
}

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