You are here

class ChainStoreResolver in Commerce Core 8.2

Default implementation of the chain store resolver.

Hierarchy

Expanded class hierarchy of ChainStoreResolver

1 file declares its use of ChainStoreResolver
ChainStoreResolverTest.php in modules/store/tests/src/Unit/Resolver/ChainStoreResolverTest.php
1 string reference to 'ChainStoreResolver'
commerce_store.services.yml in modules/store/commerce_store.services.yml
modules/store/commerce_store.services.yml
1 service uses ChainStoreResolver
commerce_store.chain_store_resolver in modules/store/commerce_store.services.yml
Drupal\commerce_store\Resolver\ChainStoreResolver

File

modules/store/src/Resolver/ChainStoreResolver.php, line 8

Namespace

Drupal\commerce_store\Resolver
View source
class ChainStoreResolver implements ChainStoreResolverInterface {

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

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

  /**
   * {@inheritdoc}
   */
  public function addResolver(StoreResolverInterface $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
ChainStoreResolver::$resolvers protected property The resolvers.
ChainStoreResolver::addResolver public function Adds a resolver. Overrides ChainStoreResolverInterface::addResolver
ChainStoreResolver::getResolvers public function Gets all added resolvers. Overrides ChainStoreResolverInterface::getResolvers
ChainStoreResolver::resolve public function Resolves the store. Overrides StoreResolverInterface::resolve
ChainStoreResolver::__construct public function Constructs a new ChainStoreResolver object.