1 | <?php |
||
18 | class TDBMSchemaAnalyzer |
||
19 | { |
||
20 | private $connection; |
||
21 | |||
22 | /** |
||
23 | * @var Schema |
||
24 | */ |
||
25 | private $schema; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | private $cachePrefix; |
||
31 | |||
32 | /** |
||
33 | * @var Cache |
||
34 | */ |
||
35 | private $cache; |
||
36 | |||
37 | /** |
||
38 | * @var SchemaAnalyzer |
||
39 | */ |
||
40 | private $schemaAnalyzer; |
||
41 | |||
42 | /** |
||
43 | * @param Connection $connection The DBAL DB connection to use |
||
44 | * @param Cache $cache A cache service to be used |
||
45 | * @param SchemaAnalyzer $schemaAnalyzer The schema analyzer that will be used to find shortest paths... |
||
46 | * Will be automatically created if not passed |
||
47 | */ |
||
48 | public function __construct(Connection $connection, Cache $cache, SchemaAnalyzer $schemaAnalyzer) |
||
54 | |||
55 | /** |
||
56 | * Returns a unique ID for the current connection. Useful for namespacing cache entries in the current connection. |
||
57 | * |
||
58 | * @return string |
||
59 | */ |
||
60 | public function getCachePrefix() |
||
68 | |||
69 | /** |
||
70 | * Returns the (cached) schema. |
||
71 | * |
||
72 | * @return Schema |
||
73 | */ |
||
74 | public function getSchema() |
||
89 | |||
90 | private function castSchemaToImmutable(Schema $schema): void |
||
98 | |||
99 | /** |
||
100 | * Changes the type of a column to an immutable date type if the type is a date. |
||
101 | * This is needed because by default, when reading a Schema, Doctrine assumes a mutable datetime. |
||
102 | */ |
||
103 | private function toImmutableType(Column $column): void |
||
117 | |||
118 | /** |
||
119 | * Returns the list of pivot tables linked to table $tableName. |
||
120 | * |
||
121 | * @param string $tableName |
||
122 | * |
||
123 | * @return array|string[] |
||
124 | */ |
||
125 | public function getPivotTableLinkedToTable($tableName) |
||
149 | |||
150 | /** |
||
151 | * Returns the list of foreign keys pointing to the table represented by this bean, excluding foreign keys |
||
152 | * from junction tables and from inheritance. |
||
153 | * It will also suppress doubles if 2 foreign keys are using the same columns. |
||
154 | * |
||
155 | * @return ForeignKeyConstraint[] |
||
156 | */ |
||
157 | public function getIncomingForeignKeys($tableName): array |
||
185 | |||
186 | /** |
||
187 | * Remove duplicate foreign keys (assumes that all foreign yes are from the same local table) |
||
188 | * |
||
189 | * @param ForeignKeyConstraint[] $foreignKeys |
||
190 | * @return ForeignKeyConstraint[] |
||
191 | */ |
||
192 | private function removeDuplicates(array $foreignKeys): array |
||
204 | } |
||
205 |