function PathAliasTestTrait::loadPathAliasByConditions

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Traits/Core/PathAliasTestTrait.php \Drupal\Tests\Traits\Core\PathAliasTestTrait::loadPathAliasByConditions()
  2. 8.9.x core/tests/Drupal/Tests/Traits/Core/PathAliasTestTrait.php \Drupal\Tests\Traits\Core\PathAliasTestTrait::loadPathAliasByConditions()
  3. 10 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::checkUrlMigration in core/modules/path/tests/src/Kernel/Migrate/d6/MigrateUrlAliasTest.php
Checks the migration results.
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 51

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;
}

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