You are here

protected function CurrencyRepository::createValueObjectFromEntity in Commerce Core 8.2

Creates a currency value object from the given entity.

Parameters

\Drupal\commerce_price\Entity\CurrencyInterface $currency: The currency entity.

Return value

\CommerceGuys\Intl\Currency\Currency The currency value object.

2 calls to CurrencyRepository::createValueObjectFromEntity()
CurrencyRepository::get in modules/price/src/Repository/CurrencyRepository.php
CurrencyRepository::getAll in modules/price/src/Repository/CurrencyRepository.php

File

modules/price/src/Repository/CurrencyRepository.php, line 91

Class

CurrencyRepository
Defines the currency repository.

Namespace

Drupal\commerce_price\Repository

Code

protected function createValueObjectFromEntity(CurrencyInterface $currency) {
  return new Currency([
    'currency_code' => $currency
      ->getCurrencyCode(),
    'name' => $currency
      ->getName(),
    'numeric_code' => $currency
      ->getNumericCode(),
    'symbol' => $currency
      ->getSymbol(),
    'fraction_digits' => $currency
      ->getFractionDigits(),
    'locale' => $currency
      ->language()
      ->getId(),
  ]);
}