You are here

function template_preprocess_commerce_store in Commerce Core 8.2

Prepares variables for store templates.

Default template: commerce-store.html.twig.

Parameters

array $variables: An associative array containing:

  • elements: An associative array containing rendered fields.
  • attributes: HTML attributes for the containing element.

File

modules/store/commerce_store.module, line 73
Defines the Store entity and associated features.

Code

function template_preprocess_commerce_store(array &$variables) {

  /** @var Drupal\commerce_store\Entity\StoreInterface $store */
  $store = $variables['elements']['#commerce_store'];
  $variables['store_entity'] = $store;
  $variables['store_url'] = $store
    ->isNew() ? '' : $store
    ->toUrl();
  $variables['store'] = [];
  foreach (Element::children($variables['elements']) as $key) {
    $variables['store'][$key] = $variables['elements'][$key];
  }
}