The store resolver is a service that determines the current store. It fires an event, sees if anything came back, if not, returns the default store.

This allows modules to select the store based on the session, url, user's country, or whatever else crosses their mind.

Comments

bojanz’s picture

Title: Create a store resolver » Create a StoreResolver
bojanz’s picture

Component: Other » Store
vasike’s picture

Parent issue: » #2464787: [Meta] Stores
bojanz’s picture

So, we need:
1) a commerce_store.services.yml file that declares a "commerce_store.resolver" service which accepts an @event.dispatcher
2) The actual \Drupal\commerce_store\StoreResolver class which accepts an event dispatcher in the __construct().
3) A \Drupal\commerce_store\StoreEvents final class (use \Drupal\Core\Render\RenderEvents as an example) with the RESOLVE = 'commerce.store.resolve' constant.
5) A custom ResolveEvent class (use PageDisplayVariantSelectionEvent as an example) which takes a store entity in the constructor and has a setStore() method.
4) The StoreResolver needs a resolve() method which will fire the RESOLVE event and pass it the ResolveEvent class.

stijndmd’s picture

stijndmd’s picture

Status: Active » Needs review
bojanz’s picture

Status: Needs review » Fixed

Thank you for your work, stijndmd!

I'm sorry it took me so long to review this, to be honest we were unsure about the architecture.
At DrupalCon we decided to go another way, and standardize all of our resolving (at that moment implemented in events, plugins and tagged services) on tagged services alone.

So I've used your patch as an example to create the NumberFormatEvent, and rewrote the store resolvers to use tagged services.

  • bojanz committed 783d0bc on
    Issue #2464759 by bojanz, stijndmd: Create a StoreResolver
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.