function MenuUiContentTranslationTest::getContentEntityByTitle

Same name in other branches
  1. 11.x core/modules/menu_ui/tests/src/Functional/MenuUiContentTranslationTest.php \Drupal\Tests\menu_ui\Functional\MenuUiContentTranslationTest::getContentEntityByTitle()

Gets a content entity object by title.

Parameters

string $entity_type_id: Id of content entity type of content entity to load.

string $title: Title of content entity to load.

Return value

\Drupal\Core\Entity\ContentEntityInterface First found content entity with given title.

1 call to MenuUiContentTranslationTest::getContentEntityByTitle()
MenuUiContentTranslationTest::testChangeContentToPseudoLanguage in core/modules/menu_ui/tests/src/Functional/MenuUiContentTranslationTest.php
Tests changing content with menu link from language to pseudo language.

File

core/modules/menu_ui/tests/src/Functional/MenuUiContentTranslationTest.php, line 88

Class

MenuUiContentTranslationTest
Tests Menu UI and Content Translation integration for content entities.

Namespace

Drupal\Tests\menu_ui\Functional

Code

protected function getContentEntityByTitle($entity_type_id, $title) {
    $entity_type_manager = $this->container
        ->get('entity_type.manager');
    $storage = $entity_type_manager->getStorage($entity_type_id);
    $storage->resetCache();
    $entities = $storage->loadByProperties([
        'title' => $title,
    ]);
    return reset($entities);
}

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