|
1 | 1 | # Doctrine Object Relational Mapper |
2 | 2 |
|
3 | | -An overview of available infrastructural code when using Doctrine's [Object Relational Mapper](http://www.doctrine-project.org/projects/orm.html). |
| 3 | +An overview of available infrastructural code when using Doctrine's [Object Relational Mapper][orm-project]. |
4 | 4 |
|
5 | | -- Requires [`doctrine/orm`](https://packagist.org/packages/doctrine/orm) |
| 5 | +- Requires [doctrine/orm] |
6 | 6 |
|
7 | 7 | ## Domain identity mapping |
8 | 8 |
|
9 | 9 | A Doctrine tailored [domain identity mapping](../ddd/identity-mapping.md) is provided by |
10 | | -`MsgPhp\Domain\Infra\Doctrine\DomainIdentityMapping`. It uses Doctrine's [`EntityManagerInterface`](http://www.doctrine-project.org/api/orm/2.5/class-Doctrine.ORM.EntityManagerInterface.html) |
11 | | -as underlying mapping. |
| 10 | +`MsgPhp\Domain\Infra\Doctrine\DomainIdentityMapping`. It uses Doctrine's [`EntityManagerInterface`][api-em] as |
| 11 | +underlying mapping. |
12 | 12 |
|
13 | 13 | - `__construct(EntityManagerInterface $em)` |
14 | 14 | - `$em`: The entity manager to use |
@@ -42,8 +42,8 @@ $mapping = new DomainIdentityMapping($em); |
42 | 42 | ## Domain repository |
43 | 43 |
|
44 | 44 | A Doctrine tailored [repository trait](../ddd/repositories.md) is provided by |
45 | | -`MsgPhp\Domain\Infra\Doctrine\DomainEntityRepositoryTrait`. It uses Doctrine's [`EntityManagerInterface`](http://www.doctrine-project.org/api/orm/2.5/class-Doctrine.ORM.EntityManagerInterface.html) |
46 | | -as underlying persistence layer. |
| 45 | +`MsgPhp\Domain\Infra\Doctrine\DomainEntityRepositoryTrait`. It uses Doctrine's [`EntityManagerInterface`][api-em] as |
| 46 | +underlying persistence layer. |
47 | 47 |
|
48 | 48 | - `__construct(string $class, EntityManagerInterface $em, DomainIdentityHelper $identityHelper = null)` |
49 | 49 | - `$class`: The entity class this repository is tied to |
@@ -102,7 +102,7 @@ if ($repository->exists($id = ['name' => ..., 'year' => ...])) { |
102 | 102 | ## Hydration |
103 | 103 |
|
104 | 104 | When working with [identifiers](../ddd/identifiers.md) and the corresponding [type](doctrine-dbal.md#domain-identifier-type) |
105 | | -a problem might occur when hydrating scalar values, e.g. using [`getScalarResult()`](http://www.doctrine-project.org/api/orm/2.5/class-Doctrine.ORM.AbstractQuery.html#_getScalarResult); |
| 105 | +a problem might occur when hydrating scalar values, e.g. using [`Query::getScalarResult()`][api-query-getscalarresult]; |
106 | 106 | it would return instances of `MsgPhp\Domain\DomainIdInterface` that can only be casted to string as its (true) scalar |
107 | 107 | value (due to `__toString()`). In case the underlying data type is e.g. `integer` we'll lose it. |
108 | 108 |
|
@@ -152,7 +152,7 @@ $query->getSingleResult(SingleScalarHydrator::NAME); // int(1) |
152 | 152 | A Doctrine tailored entity reference loader in the form of an invokable object is provided by |
153 | 153 | `MsgPhp\Domain\Infra\Doctrine\EntityReferenceLoader`. Its main purpose is to be used as a callable _reference loader_ |
154 | 154 | when working with the generic [entity aware factory](../ddd/factory/entity-aware.md#msgphpdomainfactoryentityawarefactory) |
155 | | -in effort to get a lazy-loading reference object, managed by Doctrine. See also [`EntityManagerInterface::getReference()`](http://www.doctrine-project.org/api/orm/2.5/class-Doctrine.ORM.EntityManagerInterface.html#_getReference). |
| 155 | +in effort to get a lazy-loading reference object, managed by Doctrine. See also [`EntityManagerInterface::getReference()`][api-em-getreference]. |
156 | 156 |
|
157 | 157 | - `__construct(EntityManagerInterface $em, array $classMapping = [], DomainIdentityHelper $identityHelper = null)` |
158 | 158 | - `$em`: The entity manager to use |
@@ -188,3 +188,9 @@ $loader = new EntityReferenceLoader($em); |
188 | 188 | /** @var MyEntity|null $ref */ |
189 | 189 | $ref = $loader(MyEntity::class, 1); // no database hit |
190 | 190 | ``` |
| 191 | + |
| 192 | +[orm-project]: http://www.doctrine-project.org/projects/orm.html |
| 193 | +[doctrine/orm]: https://packagist.org/packages/doctrine/orm |
| 194 | +[api-em]: http://www.doctrine-project.org/api/orm/2.5/class-Doctrine.ORM.EntityManagerInterface.html |
| 195 | +[api-em-getreference]: http://www.doctrine-project.org/api/orm/2.5/class-Doctrine.ORM.EntityManagerInterface.html#_getReference |
| 196 | +[api-query-getscalarresult]: http://www.doctrine-project.org/api/orm/2.5/class-Doctrine.ORM.AbstractQuery.html#_getScalarResult |
0 commit comments