You are here

protected function CurrencyRepository::createValueObjectFromEntity in Price 8

Same name and namespace in other branches
  1. 3.x src/Repository/CurrencyRepository.php \Drupal\price\Repository\CurrencyRepository::createValueObjectFromEntity()
  2. 2.0.x src/Repository/CurrencyRepository.php \Drupal\price\Repository\CurrencyRepository::createValueObjectFromEntity()
  3. 2.x src/Repository/CurrencyRepository.php \Drupal\price\Repository\CurrencyRepository::createValueObjectFromEntity()
  4. 3.0.x src/Repository/CurrencyRepository.php \Drupal\price\Repository\CurrencyRepository::createValueObjectFromEntity()

Creates a currency value object from the given entity.

Parameters

\Drupal\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 src/Repository/CurrencyRepository.php
CurrencyRepository::getAll in src/Repository/CurrencyRepository.php

File

src/Repository/CurrencyRepository.php, line 90

Class

CurrencyRepository
Defines the currency repository.

Namespace

Drupal\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(),
  ]);
}