Download the PHP package monro/doctrine-nullable-embedabbles without Composer
On this page you can find all versions of the php package monro/doctrine-nullable-embedabbles. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download monro/doctrine-nullable-embedabbles
More information about monro/doctrine-nullable-embedabbles
Files in monro/doctrine-nullable-embedabbles
Package doctrine-nullable-embedabbles
Short Description Workarround to the issues related of using Doctrine with embedabbles relations where the relation can be null. If the object is null doctrine would instanciate it with all the properties to null, this library will fix it to set it to null.
License MIT
Informations about the package doctrine-nullable-embedabbles
Why
The purpose of this library is to fix a known bug on doctrine where you cannot have nullable embeddables.
The issue is the following:
Given a class "A" that has an ORM relation with an embedded "B" that could be null
When an instance of "A" is loaded from DB and "B" is null
Then an instance of "B" is created with all the values to null and assigned to the property "B" of "A"
The behaviour of this library will be the following:
Given a class "A" that has an ORM relation with an embedded "B" that could be null
When an instance of "A" is loaded from DB and "B" is null
Then the property "B" of "A" is set to null
For now it only works with yml files as is what we use, if you think that will be useful to have it for XML or annotations, please open an issue
Installation
This library is mainly though to be used with symfony as it depends on its configuration files.
Syfmony
In your services.yaml (normally located at /config) Add this line:
And if you need to change the doctrine.yaml location from the default one (%kernel.project_dir%/config/packages/doctrine.yaml
), you can set the env variable DOCTRINE_CONFIG_FILE
in your .env
Usage
Define your orm mappings as usual in your YML files and on the embedded property add nullable to true wherever you want. For instance:
All versions of doctrine-nullable-embedabbles with dependencies
doctrine/common Version ^3
symfony/yaml Version >= 4.0
symfony/finder Version >= 4.0
doctrine/orm Version ^2