You are here

protected function StockLevelProcessor::computeValue in Commerce Stock 8

Get the current stock level.

1 call to StockLevelProcessor::computeValue()
StockLevelProcessor::ensureComputedValue in modules/field/src/StockLevelProcessor.php
Ensures that the stock level is only computed once.

File

modules/field/src/StockLevelProcessor.php, line 50

Class

StockLevelProcessor
Processor used by the StockLevel field.

Namespace

Drupal\commerce_stock_field

Code

protected function computeValue() {
  $entity = $this
    ->getParent()
    ->getEntity();

  /** @var \Drupal\commerce_stock\StockServiceManager $stockServiceManager */
  $stockServiceManager = \Drupal::service('commerce_stock.service_manager');
  $level = $stockServiceManager
    ->getStockLevel($entity);
  $this->processedLevel = $level;
}