Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Strategies from the service manager #34

Open
matwright opened this issue Jul 9, 2016 · 1 comment
Open

Strategies from the service manager #34

matwright opened this issue Jul 9, 2016 · 1 comment

Comments

@matwright
Copy link
Contributor

Each of the Hydrator strategies are configured in the service manager as invokable services.
However within the module, the Hydrator strategy objects are instantiated from the class directly rather than via the service manager. For example in the EmbeddedReferenceField class:

        $strategy = new EmbeddedField($this->getObjectManager());
        $strategy->setClassMetadata($this->getClassMetadata());
        $strategy->setCollectionName($this->getCollectionName());
        $strategy->setObject($value);

It prevents being able to override the strategy via the service manager.

I know it is possible to configure custom strategies per field for an entity, however sometimes it may be desirable to set specific logic for all EmbeddedFields for example and therefore an option to set a custom EmbeddedFieldsStrategy without having to configure each specific embed field in every entity.

@veewee
Copy link
Contributor

veewee commented Jul 14, 2016

The problem is that the base hydrator does not make it possible to inject any additional services.
This means this is something that could be fixed for the ODM DoctrineObject, but won't work for ORM. I would like to keep both as in-sync as possible :)

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

No branches or pull requests

2 participants