You are here

protected function PathautoGenerator::getPatternByEntityType in Pathauto 8

Loads pathauto patterns for a given entity type ID.

Parameters

string $entity_type_id: An entity type ID.

Return value

\Drupal\pathauto\PathautoPatternInterface[] A list of patterns, sorted by weight.

1 call to PathautoGenerator::getPatternByEntityType()
PathautoGenerator::getPatternByEntity in src/PathautoGenerator.php
Load an alias pattern entity by entity, bundle, and language.

File

src/PathautoGenerator.php, line 293

Class

PathautoGenerator
Provides methods for generating path aliases.

Namespace

Drupal\pathauto

Code

protected function getPatternByEntityType($entity_type_id) {
  if (!isset($this->patternsByEntityType[$entity_type_id])) {
    $ids = $this->entityTypeManager
      ->getStorage('pathauto_pattern')
      ->getQuery()
      ->condition('type', array_keys($this->aliasTypeManager
      ->getPluginDefinitionByType($this->tokenEntityMapper
      ->getTokenTypeForEntityType($entity_type_id))))
      ->condition('status', 1)
      ->sort('weight')
      ->execute();
    $this->patternsByEntityType[$entity_type_id] = $this->entityTypeManager
      ->getStorage('pathauto_pattern')
      ->loadMultiple($ids);
  }
  return $this->patternsByEntityType[$entity_type_id];
}