function QuickEditIntegrationTest::getSelectedEditor

Returns the in-place editor that quickedit selects.

Parameters

int $entity_id: An entity ID.

string $field_name: A field name.

string $view_mode: A view mode.

Return value

string Returns the selected in-place editor.

1 call to QuickEditIntegrationTest::getSelectedEditor()
QuickEditIntegrationTest::testEditorSelection in core/modules/editor/tests/src/Kernel/QuickEditIntegrationTest.php
Tests editor selection when the Editor module is present.

File

core/modules/editor/tests/src/Kernel/QuickEditIntegrationTest.php, line 123

Class

QuickEditIntegrationTest
Tests Edit module integration (Editor module's inline editing support).

Namespace

Drupal\Tests\editor\Kernel

Code

protected function getSelectedEditor($entity_id, $field_name, $view_mode = 'default') {
    $storage = $this->container
        ->get('entity_type.manager')
        ->getStorage('entity_test');
    $storage->resetCache([
        $entity_id,
    ]);
    $entity = $storage->load($entity_id);
    $items = $entity->get($field_name);
    $options = \Drupal::service('entity_display.repository')->getViewDisplay('entity_test', 'entity_test', $view_mode)
        ->getComponent($field_name);
    return $this->editorSelector
        ->getEditor($options['type'], $items);
}

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