Issues (259)

Hydration/HydrationContextInterface.php (1 issue)

1
<?php
2
/**
3
 * Copyright (C) 2018 Gerrit Addiks.
4
 * This package (including this file) was released under the terms of the GPL-3.0.
5
 * You should have received a copy of the GNU General Public License along with this program.
6
 * If not, see <http://www.gnu.org/licenses/> or send me a mail so i can send you a copy.
7
 *
8
 * @license GPL-3.0
9
 *
10
 * @author Gerrit Addiks <[email protected]>
11
 */
12
13
namespace Addiks\RDMBundle\Hydration;
14
15
use Doctrine\ORM\EntityManagerInterface;
16
use Addiks\RDMBundle\Exception\InvalidMappingException;
17
18
/**
19
 * Represents the context of one hydration-process.
20
 */
21
interface HydrationContextInterface
22
{
23
24
    /**
25
     * @return object
26
     */
27
    public function getEntity();
28
29
    /**
30
     * Get's the _effective_ absolute class of the entity.
31
     * (Resolves doctrine-proxy-classes.)
32
     *
33
     * @return class-string
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string.
Loading history...
34
     */
35
    public function getEntityClass(): string;
36
37
    /**
38
     * Allows registering of named values during hydration.
39
     *
40
     * This allows to re-use values (mostly objects) on multiple points in the mapping.
41
     * (The same object may occur in multiple different locations in an object graph.)
42
     *
43
     * @param mixed $value
44
     */
45
    public function registerValue(string $id, $value): void;
46
47
    public function hasRegisteredValue(string $id): bool;
48
49
    /**
50
     * Returns previously registered value for given $id.
51
     * Throws exception if there is no value registered for $id.
52
     * Check with hasRegisteredValue if value is registered beforehand.
53
     *
54
     * @return mixed
55
     *
56
     * @throws InvalidMappingException
57
     */
58
    public function getRegisteredValue(string $id);
59
60
    /**
61
     * Get's the current stack for cascading objects (or values) during hydration.
62
     * First entry is always the entity (root of the aggregate) itself.
63
     * Last entry is always the innermost object that is currently being hydrated.
64
     *
65
     * Example:
66
     *  [$car, $wheelSuspension, $tire, $felly]
67
     *  The root-entity (of the aggregate) is the car, but we currently hydrate the felly of the tire.
68
     */
69
    public function getObjectHydrationStack(): array;
70
71
    /**
72
     * @param object|string|null $value
73
     */
74
    public function pushOnObjectHydrationStack($value): void;
75
76
    /**
77
     * @return mixed
78
     */
79
    public function popFromObjectHydrationStack();
80
81
    public function getEntityManager(): EntityManagerInterface;
82
83
}
84