diff options
author | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
commit | bf6655a534a6775d30cafa67bd801276bda1d98d (patch) | |
tree | c6381e3f6c81c33eab72508f410b165ba05f7e9c /vendor/doctrine/orm/src/Query/TreeWalkerAdapter.php | |
parent | 94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff) | |
download | AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip |
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'vendor/doctrine/orm/src/Query/TreeWalkerAdapter.php')
-rw-r--r-- | vendor/doctrine/orm/src/Query/TreeWalkerAdapter.php | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/Query/TreeWalkerAdapter.php b/vendor/doctrine/orm/src/Query/TreeWalkerAdapter.php new file mode 100644 index 0000000..a7948db --- /dev/null +++ b/vendor/doctrine/orm/src/Query/TreeWalkerAdapter.php | |||
@@ -0,0 +1,90 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query; | ||
6 | |||
7 | use Doctrine\ORM\AbstractQuery; | ||
8 | use Doctrine\ORM\Mapping\ClassMetadata; | ||
9 | use LogicException; | ||
10 | |||
11 | use function array_diff; | ||
12 | use function array_keys; | ||
13 | use function sprintf; | ||
14 | |||
15 | /** | ||
16 | * An adapter implementation of the TreeWalker interface. The methods in this class | ||
17 | * are empty. This class exists as convenience for creating tree walkers. | ||
18 | * | ||
19 | * @psalm-import-type QueryComponent from Parser | ||
20 | */ | ||
21 | abstract class TreeWalkerAdapter implements TreeWalker | ||
22 | { | ||
23 | /** | ||
24 | * {@inheritDoc} | ||
25 | */ | ||
26 | public function __construct( | ||
27 | private readonly AbstractQuery $query, | ||
28 | private readonly ParserResult $parserResult, | ||
29 | private array $queryComponents, | ||
30 | ) { | ||
31 | } | ||
32 | |||
33 | /** | ||
34 | * {@inheritDoc} | ||
35 | */ | ||
36 | public function getQueryComponents(): array | ||
37 | { | ||
38 | return $this->queryComponents; | ||
39 | } | ||
40 | |||
41 | public function walkSelectStatement(AST\SelectStatement $selectStatement): void | ||
42 | { | ||
43 | } | ||
44 | |||
45 | public function walkUpdateStatement(AST\UpdateStatement $updateStatement): void | ||
46 | { | ||
47 | } | ||
48 | |||
49 | public function walkDeleteStatement(AST\DeleteStatement $deleteStatement): void | ||
50 | { | ||
51 | } | ||
52 | |||
53 | /** | ||
54 | * Sets or overrides a query component for a given dql alias. | ||
55 | * | ||
56 | * @psalm-param QueryComponent $queryComponent | ||
57 | */ | ||
58 | protected function setQueryComponent(string $dqlAlias, array $queryComponent): void | ||
59 | { | ||
60 | $requiredKeys = ['metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token']; | ||
61 | |||
62 | if (array_diff($requiredKeys, array_keys($queryComponent))) { | ||
63 | throw QueryException::invalidQueryComponent($dqlAlias); | ||
64 | } | ||
65 | |||
66 | $this->queryComponents[$dqlAlias] = $queryComponent; | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * Retrieves the Query Instance responsible for the current walkers execution. | ||
71 | */ | ||
72 | protected function _getQuery(): AbstractQuery | ||
73 | { | ||
74 | return $this->query; | ||
75 | } | ||
76 | |||
77 | /** | ||
78 | * Retrieves the ParserResult. | ||
79 | */ | ||
80 | protected function _getParserResult(): ParserResult | ||
81 | { | ||
82 | return $this->parserResult; | ||
83 | } | ||
84 | |||
85 | protected function getMetadataForDqlAlias(string $dqlAlias): ClassMetadata | ||
86 | { | ||
87 | return $this->queryComponents[$dqlAlias]['metadata'] | ||
88 | ?? throw new LogicException(sprintf('No metadata for DQL alias: %s', $dqlAlias)); | ||
89 | } | ||
90 | } | ||