1 | <?php |
||
10 | class MigrationExtensionManager |
||
11 | { |
||
12 | const EXTENSION_AWARE_INTERFACE_SUFFIX = 'AwareInterface'; |
||
13 | |||
14 | /** |
||
15 | * @var array {extension name} => [{extension}, {extension aware interface name}, {set extension method name}] |
||
16 | */ |
||
17 | protected $extensions = []; |
||
18 | |||
19 | /** |
||
20 | * @var AbstractPlatform |
||
21 | */ |
||
22 | protected $platform; |
||
23 | |||
24 | /** |
||
25 | * @var DbIdentifierNameGenerator |
||
26 | */ |
||
27 | protected $nameGenerator; |
||
28 | |||
29 | /** |
||
30 | * @var bool |
||
31 | */ |
||
32 | private $isDependenciesUpToDate = false; |
||
33 | |||
34 | /** |
||
35 | * Sets a database platform |
||
36 | * |
||
37 | * @param AbstractPlatform $platform |
||
38 | */ |
||
39 | public function setDatabasePlatform(AbstractPlatform $platform) |
||
49 | |||
50 | /** |
||
51 | * Sets a database identifier name generator |
||
52 | * |
||
53 | * @param DbIdentifierNameGenerator $nameGenerator |
||
54 | */ |
||
55 | public function setNameGenerator(DbIdentifierNameGenerator $nameGenerator) |
||
65 | |||
66 | /** |
||
67 | * Registers an extension |
||
68 | * |
||
69 | * @param string $name The extension name |
||
70 | * @param object $extension The extension object |
||
71 | */ |
||
72 | public function addExtension($name, $extension) |
||
90 | |||
91 | /** |
||
92 | * Sets extensions to the given migration |
||
93 | * |
||
94 | * @param Migration $migration |
||
95 | */ |
||
96 | public function applyExtensions(Migration $migration) |
||
107 | |||
108 | /** |
||
109 | * Makes sure that links on depended each other extensions set |
||
110 | */ |
||
111 | protected function ensureExtensionDependenciesApplied() |
||
120 | |||
121 | /** |
||
122 | * Sets extensions to the given object |
||
123 | * |
||
124 | * @param object $obj |
||
125 | */ |
||
126 | protected function applyExtensionDependencies($obj) |
||
135 | |||
136 | /** |
||
137 | * Gets an name of interface which should be used to register an extension in a migration class |
||
138 | * |
||
139 | * @param object $extension |
||
140 | * @return string |
||
141 | * @throws \RuntimeException if the interface is not found |
||
142 | */ |
||
143 | protected function getExtensionAwareInterfaceName($extension) |
||
177 | |||
178 | /** |
||
179 | * Gets a name of set extension method |
||
180 | * |
||
181 | * @param string $extensionAwareInterfaceName |
||
182 | * @return string |
||
183 | * @throws \RuntimeException if set method is not found |
||
184 | */ |
||
185 | protected function getSetExtensionMethodName($extensionAwareInterfaceName) |
||
200 | } |
||
201 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: