You are here

protected function PathAliasTestTrait::loadPathAliasByConditions in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Traits/Core/PathAliasTestTrait.php \Drupal\Tests\Traits\Core\PathAliasTestTrait::loadPathAliasByConditions()
  2. 9 core/tests/Drupal/Tests/Traits/Core/PathAliasTestTrait.php \Drupal\Tests\Traits\Core\PathAliasTestTrait::loadPathAliasByConditions()

Gets the first result from a 'load by properties' storage call.

Parameters

array $conditions: An array of query conditions.

Return value

\Drupal\path_alias\PathAliasInterface|null A path alias entity or NULL.

3 calls to PathAliasTestTrait::loadPathAliasByConditions()
MigrateUrlAliasTest::testUrlAlias in core/modules/path/tests/src/Kernel/Migrate/d6/MigrateUrlAliasTest.php
Tests the url alias migration.
MigrateUrlAliasTest::testUrlAliasWithTranslatedNodes in core/modules/path/tests/src/Kernel/Migrate/d7/MigrateUrlAliasTest.php
Tests the URL alias migration with translated nodes.
MigrateUrlAliasTestBase::testUrlAlias in core/modules/path/tests/src/Kernel/Migrate/d7/MigrateUrlAliasTestBase.php
Tests the URL alias migration.

File

core/tests/Drupal/Tests/Traits/Core/PathAliasTestTrait.php, line 49

Class

PathAliasTestTrait
Provides methods to create and assert path_alias entities.

Namespace

Drupal\Tests\Traits\Core

Code

protected function loadPathAliasByConditions($conditions) {
  $storage = \Drupal::entityTypeManager()
    ->getStorage('path_alias');
  $query = $storage
    ->getQuery()
    ->accessCheck(FALSE);
  foreach ($conditions as $field => $value) {
    $query
      ->condition($field, $value);
  }
  $entities = $storage
    ->loadMultiple($query
    ->execute());
  return $entities ? reset($entities) : NULL;
}