Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final prevents Doctrine Embeddable with annotations to work #4

Open
ste93cry opened this issue Dec 9, 2015 · 1 comment
Open

Final prevents Doctrine Embeddable with annotations to work #4

ste93cry opened this issue Dec 9, 2015 · 1 comment

Comments

@ste93cry
Copy link

ste93cry commented Dec 9, 2015

I'm trying to use your library with Doctrine 2.5 embeddable objects. Unfortunately, this is impossible because I'm using annotations instead of YAML and the docblock must be applied to the properties. I can't extend the class to do it because you marked it as final. I know there has already been a long discussion about why you decided to restrict users from inheriting the Money class, but this makes this whole library unusable for anyone using annotations (that are really common on Symfony).

@flaushi
Copy link

flaushi commented Jul 18, 2018

I am trying to realise exactly the same.
My entities all use annotations, and I don't know how to register the Money\Money type.

I have this in my entity:

 /**
 * @ORM\Column(type="decimal", precision=20, scale=2)
 * #@ORM\Embedded(class="Money\Money")
 */
private $value;

and in my config.yml

doctrine:
    dbal:
        types:
            EnumIntervalType: AppBundle\DBAL\Types\EnumIntervalType
            EnumActionType: AppBundle\DBAL\Types\EnumActionType
            Money\Money:
                type: embeddable
                fields:
                    amount: { type: decimal, precision: 10, scale: 2 }
                embedded:
                    currency:
                        class: Money\Currency
            Money\Currency:
                type: embeddable
                fields:
                    code: { type: string, length: 3 }

However, this is not an accepted configuration, I get

Unrecognized options "type, fields, embedded" under "doctrine.dbal.types.Money\Money"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@ste93cry @flaushi and others