moneyphp / money

PHP implementation of Fowler's Money pattern.
http://moneyphp.org
MIT License
4.62k stars 440 forks source link

feat: add un/serialize for currency #779

Closed Chris53897 closed 8 months ago

Chris53897 commented 8 months ago

We use https://github.com/doctrine-extensions/DoctrineExtensions for Versioning. I came across the problem, that versioning does not work for Curreny. Symfony via https://github.com/TheBigBrainsCompany/TbbcMoneyBundle

We use this Attribut.

#[ORM\Column(options: ['default' => 'EUR'])]
#[Gedmo\Versioned]
public $currency = null;
public function setCurrency(Currency $currency): self
    {
        $this->currency = $currency;
        return $this;
    }

    public function getCurrency(): Currency
    {
        return new Currency($this->currency);
    }

This PR solves the problem for us. But i am not sure if we use it, how it should be used. Sideeffekts of this PR?

frederikbosch commented 8 months ago

We will not implement. We have parsers and formatters. Regarding ORM mapping: this should be fixed inside the ORM layer.