You are here

public function Token::getSku in Commerce AutoSKU 8.2

Overrides CommerceAutoSkuGeneratorBase::getSku

File

src/Plugin/CommerceAutoSkuGenerator/Token.php, line 96

Class

Token
Provides the token commerce_autosku generator.

Namespace

Drupal\commerce_autosku\Plugin\CommerceAutoSkuGenerator

Code

public function getSku(ProductVariationInterface $entity) {
  $entity_type = $entity
    ->getEntityTypeId();
  $configuration = $this
    ->getConfiguration();

  // Pass empty BubbleableMetadata object to explicitly ignore cacheablity,
  // as the result is never rendered.
  $sku = $this->token
    ->replace($configuration['pattern'], [
    $entity_type => $entity,
  ], [
    'sanitize' => FALSE,
    'clear' => TRUE,
  ], new BubbleableMetadata());
  return $sku;
}