function EditorSelectionTest::getSelectedEditor

Same name in other branches
  1. 8.9.x core/modules/quickedit/tests/src/Kernel/EditorSelectionTest.php \Drupal\Tests\quickedit\Kernel\EditorSelectionTest::getSelectedEditor()

Returns the in-place editor that Quick Edit selects.

3 calls to EditorSelectionTest::getSelectedEditor()
EditorSelectionTest::testNumber in core/modules/quickedit/tests/src/Kernel/EditorSelectionTest.php
Tests a number field, with cardinality 1 and >1.
EditorSelectionTest::testText in core/modules/quickedit/tests/src/Kernel/EditorSelectionTest.php
Tests a string (plain text) field, with cardinality 1 and >1.
EditorSelectionTest::testTextWysiwyg in core/modules/quickedit/tests/src/Kernel/EditorSelectionTest.php
Tests a textual field with varying text format compatibility.

File

core/modules/quickedit/tests/src/Kernel/EditorSelectionTest.php, line 43

Class

EditorSelectionTest
Tests in-place field editor selection.

Namespace

Drupal\Tests\quickedit\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.