Doctrine\Common\Persistence\PersistentObject
PersistentObject base class that implements getter/setter methods for all mapped fields and associations by overriding __call.
This class is a forward compatible implementation of the PersistentObject trait.
Limitations:
1. All persistent objects have to be associated with a single ObjectManager, multiple
ObjectManagers are not supported. You can set the ObjectManager with `PersistentObject#setObjectManager()`.
2. Setters and getters only work if a ClassMetadata instance was injected into the PersistentObject.
This is either done on `postLoad` of an object or by accessing the global object manager.
3. There are no hooks for setters/getters. Just implement the method yourself instead of relying on __call().
4. Slower than handcoded implementations: An average of 7 method calls per access to a field and 11 for an association.
5. Only the inverse side associations get autoset on the owning side aswell. Setting objects on the owning side
will not set the inverse side associations.
- Author: Benjamin Eberlei <kontakt@beberlei.de>
Synopsis
- // members
- private ObjectManager $objectManager;
- private ClassMetadata $cm;
- // methods
- public static void setObjectManager()
- public static ObjectManager getObjectManager()
- public void injectObjectManager()
- private void set()
- private mixed get()
- private void completeOwningSide()
- private void add()
- private void initializeDoctrine()
- public mixed __call()
Hierarchy
Members
private
- $cm — Doctrine\Common\Persistence\Mapping\ClassMetadata
- $objectManager — Doctrine\Common\Persistence\ObjectManager
Methods
private
- add() — Add an object to a collection
- completeOwningSide() — If this is an inverse side association complete the owning side.
- get() — Get persistent field value.
- initializeDoctrine() — Initialize Doctrine Metadata for this class.
- set() — Sets a persistent fields value.
public
- __call() — Magic method that implements
- getObjectManager()
- injectObjectManager() — Inject Doctrine Object Manager
- setObjectManager() — Set the object manager responsible for all persistent object base classes.