diff options
Diffstat (limited to 'vendor/doctrine/orm/src/Cache/EntityCacheEntry.php')
-rw-r--r-- | vendor/doctrine/orm/src/Cache/EntityCacheEntry.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/Cache/EntityCacheEntry.php b/vendor/doctrine/orm/src/Cache/EntityCacheEntry.php new file mode 100644 index 0000000..69bc813 --- /dev/null +++ b/vendor/doctrine/orm/src/Cache/EntityCacheEntry.php | |||
@@ -0,0 +1,50 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Cache; | ||
6 | |||
7 | use Doctrine\ORM\EntityManagerInterface; | ||
8 | |||
9 | use function array_map; | ||
10 | |||
11 | class EntityCacheEntry implements CacheEntry | ||
12 | { | ||
13 | /** | ||
14 | * @param array<string,mixed> $data The entity map data | ||
15 | * @psalm-param class-string $class The entity class name | ||
16 | */ | ||
17 | public function __construct( | ||
18 | public readonly string $class, | ||
19 | public readonly array $data, | ||
20 | ) { | ||
21 | } | ||
22 | |||
23 | /** | ||
24 | * Creates a new EntityCacheEntry | ||
25 | * | ||
26 | * This method allows Doctrine\Common\Cache\PhpFileCache compatibility | ||
27 | * | ||
28 | * @param array<string,mixed> $values array containing property values | ||
29 | */ | ||
30 | public static function __set_state(array $values): self | ||
31 | { | ||
32 | return new self($values['class'], $values['data']); | ||
33 | } | ||
34 | |||
35 | /** | ||
36 | * Retrieves the entity data resolving cache entries | ||
37 | * | ||
38 | * @return array<string, mixed> | ||
39 | */ | ||
40 | public function resolveAssociationEntries(EntityManagerInterface $em): array | ||
41 | { | ||
42 | return array_map(static function ($value) use ($em) { | ||
43 | if (! ($value instanceof AssociationCacheEntry)) { | ||
44 | return $value; | ||
45 | } | ||
46 | |||
47 | return $em->getReference($value->class, $value->identifier); | ||
48 | }, $this->data); | ||
49 | } | ||
50 | } | ||