PHP code example of amberovsky / currency-doctrine
1. Go to this page and download the library: Download amberovsky/currency-doctrine library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
amberovsky / currency-doctrine example snippets
/**
* @inheritDoc
*/
protected function initializeContainer() {
parent::initializeContainer();
if (!Type::hasType(CurrencyType::NAME)) {
Type::addType(CurrencyType::NAME, CurrencyType::class);
/** @var CurrencyType $currencyType */
$currencyType = Type::getType(CurrencyType::NAME);
$currencyType->setCurrencyFactory($this->container->get(CurrencyFactory::class));
}
}
php
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="invoices")
*/
class Invoice
{
/**
* @ORM\Column(type="Currency")
*/
private Currency $currency;
public function getCurrency(): Currency {
return $this->currency;
}
}