You are here

function EntityReferenceRevisionsAutocompleteTest::drupalGetBlockByInfo in Entity Reference Revisions 8

Get a custom block from the database based on its title.

Parameters

$info: A block title, usually generated by $this->randomMachineName().

$reset: (optional) Whether to reset the entity cache.

Return value

\Drupal\block\BlockInterface A block entity matching $info.

1 call to EntityReferenceRevisionsAutocompleteTest::drupalGetBlockByInfo()
EntityReferenceRevisionsAutocompleteTest::testEntityReferenceRevisionsAutocompleteProcessing in tests/src/Functional/EntityReferenceRevisionsAutocompleteTest.php
Test for autocomplete processing.

File

tests/src/Functional/EntityReferenceRevisionsAutocompleteTest.php, line 124

Class

EntityReferenceRevisionsAutocompleteTest
Tests the entity_reference_revisions autocomplete.

Namespace

Drupal\Tests\entity_reference_revisions\Functional

Code

function drupalGetBlockByInfo($info, $reset = FALSE) {
  if ($reset) {
    \Drupal::entityTypeManager()
      ->getStorage('block_content')
      ->resetCache();
  }
  $blocks = \Drupal::entityTypeManager()
    ->getStorage('block_content')
    ->loadByProperties(array(
    'info' => $info,
  ));

  // Get the first block returned from the database.
  $returned_block = reset($blocks);
  return $returned_block;
}