You are here

class ChainLocaleResolver in Price 3.x

Same name and namespace in other branches
  1. 8 src/Resolver/ChainLocaleResolver.php \Drupal\price\Resolver\ChainLocaleResolver
  2. 2.0.x src/Resolver/ChainLocaleResolver.php \Drupal\price\Resolver\ChainLocaleResolver
  3. 2.x src/Resolver/ChainLocaleResolver.php \Drupal\price\Resolver\ChainLocaleResolver
  4. 3.0.x src/Resolver/ChainLocaleResolver.php \Drupal\price\Resolver\ChainLocaleResolver

Default implementation of the chain locale resolver.

Hierarchy

Expanded class hierarchy of ChainLocaleResolver

1 string reference to 'ChainLocaleResolver'
price.services.yml in ./price.services.yml
price.services.yml
1 service uses ChainLocaleResolver
price.chain_locale_resolver in ./price.services.yml
Drupal\price\Resolver\ChainLocaleResolver

File

src/Resolver/ChainLocaleResolver.php, line 8

Namespace

Drupal\price\Resolver
View source
class ChainLocaleResolver implements ChainLocaleResolverInterface {

  /**
   * The resolvers.
   *
   * @var \Drupal\price\Resolver\LocaleResolverInterface[]
   */
  protected $resolvers = [];

  /**
   * Constructs a new ChainLocaleResolver object.
   *
   * @param \Drupal\price\Resolver\LocaleResolverInterface[] $resolvers
   *   The resolvers.
   */
  public function __construct(array $resolvers = []) {
    $this->resolvers = $resolvers;
  }

  /**
   * {@inheritdoc}
   */
  public function addResolver(LocaleResolverInterface $resolver) {
    $this->resolvers[] = $resolver;
  }

  /**
   * {@inheritdoc}
   */
  public function getResolvers() {
    return $this->resolvers;
  }

  /**
   * {@inheritdoc}
   */
  public function resolve() {
    foreach ($this->resolvers as $resolver) {
      $result = $resolver
        ->resolve();
      if ($result) {
        return $result;
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ChainLocaleResolver::$resolvers protected property The resolvers.
ChainLocaleResolver::addResolver public function Adds a resolver. Overrides ChainLocaleResolverInterface::addResolver
ChainLocaleResolver::getResolvers public function Gets all added resolvers. Overrides ChainLocaleResolverInterface::getResolvers
ChainLocaleResolver::resolve public function Resolves the locale. Overrides LocaleResolverInterface::resolve
ChainLocaleResolver::__construct public function Constructs a new ChainLocaleResolver object.