@@ -25,258 +25,258 @@ |
||
25 | 25 | */ |
26 | 26 | class TdbmInstallController extends Controller |
27 | 27 | { |
28 | - /** |
|
29 | - * @var HtmlBlock |
|
30 | - */ |
|
31 | - public $content; |
|
32 | - |
|
33 | - public $selfedit; |
|
34 | - |
|
35 | - /** |
|
36 | - * The active MoufManager to be edited/viewed. |
|
37 | - * |
|
38 | - * @var MoufManager |
|
39 | - */ |
|
40 | - public $moufManager; |
|
41 | - |
|
42 | - /** |
|
43 | - * The template used by the main page for mouf. |
|
44 | - * |
|
45 | - * @Property |
|
46 | - * @Compulsory |
|
47 | - * |
|
48 | - * @var TemplateInterface |
|
49 | - */ |
|
50 | - public $template; |
|
51 | - |
|
52 | - /** |
|
53 | - * Displays the first install screen. |
|
54 | - * |
|
55 | - * @Action |
|
56 | - * @Logged |
|
57 | - * |
|
58 | - * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only) |
|
59 | - */ |
|
60 | - public function defaultAction($selfedit = 'false') |
|
61 | - { |
|
62 | - $this->selfedit = $selfedit; |
|
63 | - |
|
64 | - if ($selfedit == 'true') { |
|
65 | - $this->moufManager = MoufManager::getMoufManager(); |
|
66 | - } else { |
|
67 | - $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); |
|
68 | - } |
|
69 | - |
|
70 | - $this->content->addFile(__DIR__.'/../../../../views/installStep1.php', $this); |
|
71 | - $this->template->toHtml(); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Skips the install process. |
|
76 | - * |
|
77 | - * @Action |
|
78 | - * @Logged |
|
79 | - * |
|
80 | - * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only) |
|
81 | - */ |
|
82 | - public function skip($selfedit = 'false') |
|
83 | - { |
|
84 | - InstallUtils::continueInstall($selfedit == 'true'); |
|
85 | - } |
|
86 | - |
|
87 | - protected $daoNamespace; |
|
88 | - protected $beanNamespace; |
|
89 | - protected $autoloadDetected; |
|
90 | - //protected $storeInUtc; |
|
91 | - protected $useCustomComposer = false; |
|
92 | - protected $composerFile; |
|
93 | - |
|
94 | - /** |
|
95 | - * Displays the second install screen. |
|
96 | - * |
|
97 | - * @Action |
|
98 | - * @Logged |
|
99 | - * |
|
100 | - * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only) |
|
101 | - */ |
|
102 | - public function configure($selfedit = 'false') |
|
103 | - { |
|
104 | - $this->selfedit = $selfedit; |
|
105 | - |
|
106 | - if ($selfedit == 'true') { |
|
107 | - $this->moufManager = MoufManager::getMoufManager(); |
|
108 | - } else { |
|
109 | - $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); |
|
110 | - } |
|
111 | - |
|
112 | - // Let's start by performing basic checks about the instances we assume to exist. |
|
113 | - if (!$this->moufManager->instanceExists('dbalConnection')) { |
|
114 | - $this->displayErrorMsg("The TDBM install process assumes your database connection instance is already created, and that the name of this instance is 'dbalConnection'. Could not find the 'dbalConnection' instance."); |
|
115 | - |
|
116 | - return; |
|
117 | - } |
|
118 | - |
|
119 | - if ($this->moufManager->has('tdbmConfiguration')) { |
|
120 | - $tdbmConfiguration = $this->moufManager->getInstanceDescriptor('tdbmConfiguration'); |
|
121 | - |
|
122 | - $this->beanNamespace = $tdbmConfiguration->getConstructorArgumentProperty('beanNamespace')->getValue(); |
|
123 | - $this->daoNamespace = $tdbmConfiguration->getConstructorArgumentProperty('daoNamespace')->getValue(); |
|
124 | - } else { |
|
125 | - // Old TDBM 4.2 fallback |
|
126 | - $this->daoNamespace = $this->moufManager->getVariable('tdbmDefaultDaoNamespace_tdbmService'); |
|
127 | - $this->beanNamespace = $this->moufManager->getVariable('tdbmDefaultBeanNamespace_tdbmService'); |
|
128 | - } |
|
129 | - |
|
130 | - if ($this->daoNamespace == null && $this->beanNamespace == null) { |
|
131 | - $classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json'); |
|
132 | - |
|
133 | - $autoloadNamespaces = $classNameMapper->getManagedNamespaces(); |
|
134 | - if ($autoloadNamespaces) { |
|
135 | - $this->autoloadDetected = true; |
|
136 | - $rootNamespace = $autoloadNamespaces[0]; |
|
137 | - $this->daoNamespace = $rootNamespace.'Dao'; |
|
138 | - $this->beanNamespace = $rootNamespace.'Model'; |
|
139 | - } else { |
|
140 | - $this->autoloadDetected = false; |
|
141 | - $this->daoNamespace = 'YourApplication\\Dao'; |
|
142 | - $this->beanNamespace = 'YourApplication\\Model'; |
|
143 | - } |
|
144 | - } else { |
|
145 | - $this->autoloadDetected = true; |
|
146 | - } |
|
147 | - $this->defaultPath = true; |
|
148 | - $this->storePath = ''; |
|
149 | - |
|
150 | - $this->castDatesToDateTime = true; |
|
151 | - |
|
152 | - $this->content->addFile(__DIR__.'/../../../../views/installStep2.php', $this); |
|
153 | - $this->template->toHtml(); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * This action generates the TDBM instance, then the DAOs and Beans. |
|
158 | - * |
|
159 | - * @Action |
|
160 | - * |
|
161 | - * @param string $daonamespace |
|
162 | - * @param string $beannamespace |
|
163 | - * @param string $selfedit |
|
164 | - * |
|
165 | - * @throws \Mouf\MoufException |
|
166 | - */ |
|
167 | - public function generate($daonamespace, $beannamespace, /*$storeInUtc = 0,*/ $selfedit = 'false', $defaultPath = false, $storePath = '') |
|
168 | - { |
|
169 | - $this->selfedit = $selfedit; |
|
170 | - |
|
171 | - if ($selfedit == 'true') { |
|
172 | - $this->moufManager = MoufManager::getMoufManager(); |
|
173 | - } else { |
|
174 | - $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); |
|
175 | - } |
|
176 | - |
|
177 | - $doctrineCache = $this->moufManager->getInstanceDescriptor('defaultDoctrineCache'); |
|
178 | - |
|
179 | - $migratingFrom42 = false; |
|
180 | - if ($this->moufManager->has('tdbmService') && !$this->moufManager->has('tdbmConfiguration')) { |
|
181 | - $migratingFrom42 = true; |
|
182 | - } |
|
183 | - |
|
184 | - if ($this->moufManager->has('tdbmService') && $this->moufManager->getInstanceDescriptor('tdbmService')->getClassName() === 'Mouf\\Database\\TDBM\\TDBMService') { |
|
185 | - $this->migrateNamespaceTo50($this->moufManager); |
|
186 | - } |
|
187 | - |
|
188 | - $annotationParser = InstallUtils::getOrCreateInstance(AnnotationParser::class, AnnotationParser::class, $this->moufManager); |
|
189 | - $annotationParser->getConstructorArgumentProperty('annotations')->setValue([ |
|
190 | - 'UUID' => UUID::class, |
|
191 | - 'Autoincrement' => Autoincrement::class, |
|
192 | - 'Bean' => Bean::class |
|
193 | - ]); |
|
194 | - |
|
195 | - $namingStrategy = InstallUtils::getOrCreateInstance('namingStrategy', DefaultNamingStrategy::class, $this->moufManager); |
|
196 | - if ($migratingFrom42) { |
|
197 | - // Let's setup the naming strategy for compatibility |
|
198 | - $namingStrategy->getSetterProperty('setBeanPrefix')->setValue(''); |
|
199 | - $namingStrategy->getSetterProperty('setBeanSuffix')->setValue('Bean'); |
|
200 | - $namingStrategy->getSetterProperty('setBaseBeanPrefix')->setValue(''); |
|
201 | - $namingStrategy->getSetterProperty('setBaseBeanSuffix')->setValue('BaseBean'); |
|
202 | - $namingStrategy->getSetterProperty('setDaoPrefix')->setValue(''); |
|
203 | - $namingStrategy->getSetterProperty('setDaoSuffix')->setValue('Dao'); |
|
204 | - $namingStrategy->getSetterProperty('setBaseDaoPrefix')->setValue(''); |
|
205 | - $namingStrategy->getSetterProperty('setBaseDaoSuffix')->setValue('BaseDao'); |
|
206 | - } |
|
207 | - if ($namingStrategy->getClassName() === DefaultNamingStrategy::class) { |
|
208 | - $namingStrategy->getConstructorArgumentProperty('annotationParser')->setValue($this->moufManager->getInstanceDescriptor(AnnotationParser::class)); |
|
209 | - $namingStrategy->getConstructorArgumentProperty('schemaManager')->setOrigin('php')->setValue('return $container->get(\'dbalConnection\')->getSchemaManager();'); |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - if (!$this->moufManager->instanceExists('tdbmConfiguration')) { |
|
214 | - $moufListener = InstallUtils::getOrCreateInstance(MoufDiListener::class, MoufDiListener::class, $this->moufManager); |
|
215 | - |
|
216 | - $tdbmConfiguration = $this->moufManager->createInstance(MoufConfiguration::class)->setName('tdbmConfiguration'); |
|
217 | - $tdbmConfiguration->getConstructorArgumentProperty('connection')->setValue($this->moufManager->getInstanceDescriptor('dbalConnection')); |
|
218 | - $tdbmConfiguration->getConstructorArgumentProperty('cache')->setValue($doctrineCache); |
|
219 | - $tdbmConfiguration->getConstructorArgumentProperty('namingStrategy')->setValue($namingStrategy); |
|
220 | - $tdbmConfiguration->getProperty('daoFactoryInstanceName')->setValue('daoFactory'); |
|
221 | - $tdbmConfiguration->getConstructorArgumentProperty('generatorListeners')->setValue([$moufListener]); |
|
222 | - |
|
223 | - // Let's also delete the tdbmService if migrating versions <= 4.2 |
|
224 | - if ($migratingFrom42) { |
|
225 | - $this->moufManager->removeComponent('tdbmService'); |
|
226 | - } |
|
227 | - } else { |
|
228 | - $tdbmConfiguration = $this->moufManager->getInstanceDescriptor('tdbmConfiguration'); |
|
229 | - } |
|
230 | - |
|
231 | - if (!$this->moufManager->instanceExists('tdbmService')) { |
|
232 | - $tdbmService = $this->moufManager->createInstance('TheCodingMachine\\TDBM\\TDBMService')->setName('tdbmService'); |
|
233 | - $tdbmService->getConstructorArgumentProperty('configuration')->setValue($tdbmConfiguration); |
|
234 | - } |
|
235 | - |
|
236 | - // We declare our instance of the Symfony command as a Mouf instance |
|
237 | - $generateCommand = InstallUtils::getOrCreateInstance('generateCommand', GenerateCommand::class, $this->moufManager); |
|
238 | - $generateCommand->getConstructorArgumentProperty('configuration')->setValue($tdbmConfiguration); |
|
239 | - |
|
240 | - // We register that instance descriptor using "ConsoleUtils" |
|
241 | - $consoleUtils = new ConsoleUtils($this->moufManager); |
|
242 | - $consoleUtils->registerCommand($generateCommand); |
|
243 | - |
|
244 | - $this->moufManager->rewriteMouf(); |
|
245 | - |
|
246 | - TdbmController::generateDaos($this->moufManager, 'tdbmService', $daonamespace, $beannamespace, 'daoFactory', $selfedit, /*$storeInUtc,*/ $defaultPath, $storePath); |
|
247 | - |
|
248 | - InstallUtils::continueInstall($selfedit == 'true'); |
|
249 | - } |
|
250 | - |
|
251 | - protected $errorMsg; |
|
252 | - |
|
253 | - private function displayErrorMsg($msg) |
|
254 | - { |
|
255 | - $this->errorMsg = $msg; |
|
256 | - $this->content->addFile(__DIR__.'/../../../../views/installError.php', $this); |
|
257 | - $this->template->toHtml(); |
|
258 | - } |
|
259 | - |
|
260 | - /** |
|
261 | - * Migrate classes from old 4.x namespace (Mouf\Database\TDBM) to new 5.x namespace (TheCodingMachine\TDBM) |
|
262 | - * |
|
263 | - * @param MoufManager $moufManager |
|
264 | - */ |
|
265 | - private function migrateNamespaceTo50(MoufManager $moufManager) |
|
266 | - { |
|
267 | - $instanceList = $moufManager->getInstancesList(); |
|
268 | - |
|
269 | - $migratedClasses = [ |
|
270 | - 'Mouf\\Database\\TDBM\\Configuration' => 'TheCodingMachine\\TDBM\\Configuration', |
|
271 | - 'Mouf\\Database\\TDBM\\TDBMService' => 'TheCodingMachine\\TDBM\\TDBMService', |
|
272 | - 'Mouf\\Database\\TDBM\\Commands\\GenerateCommand' => 'TheCodingMachine\\TDBM\\Commands\\GenerateCommand', |
|
273 | - 'Mouf\\Database\\TDBM\\Utils\\DefaultNamingStrategy' => 'TheCodingMachine\\TDBM\\Utils\\DefaultNamingStrategy', |
|
274 | - ]; |
|
275 | - |
|
276 | - foreach ($instanceList as $instanceName => $className) { |
|
277 | - if (isset($migratedClasses[$className])) { |
|
278 | - $moufManager->alterClass($instanceName, $migratedClasses[$className]); |
|
279 | - } |
|
280 | - } |
|
281 | - } |
|
28 | + /** |
|
29 | + * @var HtmlBlock |
|
30 | + */ |
|
31 | + public $content; |
|
32 | + |
|
33 | + public $selfedit; |
|
34 | + |
|
35 | + /** |
|
36 | + * The active MoufManager to be edited/viewed. |
|
37 | + * |
|
38 | + * @var MoufManager |
|
39 | + */ |
|
40 | + public $moufManager; |
|
41 | + |
|
42 | + /** |
|
43 | + * The template used by the main page for mouf. |
|
44 | + * |
|
45 | + * @Property |
|
46 | + * @Compulsory |
|
47 | + * |
|
48 | + * @var TemplateInterface |
|
49 | + */ |
|
50 | + public $template; |
|
51 | + |
|
52 | + /** |
|
53 | + * Displays the first install screen. |
|
54 | + * |
|
55 | + * @Action |
|
56 | + * @Logged |
|
57 | + * |
|
58 | + * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only) |
|
59 | + */ |
|
60 | + public function defaultAction($selfedit = 'false') |
|
61 | + { |
|
62 | + $this->selfedit = $selfedit; |
|
63 | + |
|
64 | + if ($selfedit == 'true') { |
|
65 | + $this->moufManager = MoufManager::getMoufManager(); |
|
66 | + } else { |
|
67 | + $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); |
|
68 | + } |
|
69 | + |
|
70 | + $this->content->addFile(__DIR__.'/../../../../views/installStep1.php', $this); |
|
71 | + $this->template->toHtml(); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * Skips the install process. |
|
76 | + * |
|
77 | + * @Action |
|
78 | + * @Logged |
|
79 | + * |
|
80 | + * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only) |
|
81 | + */ |
|
82 | + public function skip($selfedit = 'false') |
|
83 | + { |
|
84 | + InstallUtils::continueInstall($selfedit == 'true'); |
|
85 | + } |
|
86 | + |
|
87 | + protected $daoNamespace; |
|
88 | + protected $beanNamespace; |
|
89 | + protected $autoloadDetected; |
|
90 | + //protected $storeInUtc; |
|
91 | + protected $useCustomComposer = false; |
|
92 | + protected $composerFile; |
|
93 | + |
|
94 | + /** |
|
95 | + * Displays the second install screen. |
|
96 | + * |
|
97 | + * @Action |
|
98 | + * @Logged |
|
99 | + * |
|
100 | + * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only) |
|
101 | + */ |
|
102 | + public function configure($selfedit = 'false') |
|
103 | + { |
|
104 | + $this->selfedit = $selfedit; |
|
105 | + |
|
106 | + if ($selfedit == 'true') { |
|
107 | + $this->moufManager = MoufManager::getMoufManager(); |
|
108 | + } else { |
|
109 | + $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); |
|
110 | + } |
|
111 | + |
|
112 | + // Let's start by performing basic checks about the instances we assume to exist. |
|
113 | + if (!$this->moufManager->instanceExists('dbalConnection')) { |
|
114 | + $this->displayErrorMsg("The TDBM install process assumes your database connection instance is already created, and that the name of this instance is 'dbalConnection'. Could not find the 'dbalConnection' instance."); |
|
115 | + |
|
116 | + return; |
|
117 | + } |
|
118 | + |
|
119 | + if ($this->moufManager->has('tdbmConfiguration')) { |
|
120 | + $tdbmConfiguration = $this->moufManager->getInstanceDescriptor('tdbmConfiguration'); |
|
121 | + |
|
122 | + $this->beanNamespace = $tdbmConfiguration->getConstructorArgumentProperty('beanNamespace')->getValue(); |
|
123 | + $this->daoNamespace = $tdbmConfiguration->getConstructorArgumentProperty('daoNamespace')->getValue(); |
|
124 | + } else { |
|
125 | + // Old TDBM 4.2 fallback |
|
126 | + $this->daoNamespace = $this->moufManager->getVariable('tdbmDefaultDaoNamespace_tdbmService'); |
|
127 | + $this->beanNamespace = $this->moufManager->getVariable('tdbmDefaultBeanNamespace_tdbmService'); |
|
128 | + } |
|
129 | + |
|
130 | + if ($this->daoNamespace == null && $this->beanNamespace == null) { |
|
131 | + $classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json'); |
|
132 | + |
|
133 | + $autoloadNamespaces = $classNameMapper->getManagedNamespaces(); |
|
134 | + if ($autoloadNamespaces) { |
|
135 | + $this->autoloadDetected = true; |
|
136 | + $rootNamespace = $autoloadNamespaces[0]; |
|
137 | + $this->daoNamespace = $rootNamespace.'Dao'; |
|
138 | + $this->beanNamespace = $rootNamespace.'Model'; |
|
139 | + } else { |
|
140 | + $this->autoloadDetected = false; |
|
141 | + $this->daoNamespace = 'YourApplication\\Dao'; |
|
142 | + $this->beanNamespace = 'YourApplication\\Model'; |
|
143 | + } |
|
144 | + } else { |
|
145 | + $this->autoloadDetected = true; |
|
146 | + } |
|
147 | + $this->defaultPath = true; |
|
148 | + $this->storePath = ''; |
|
149 | + |
|
150 | + $this->castDatesToDateTime = true; |
|
151 | + |
|
152 | + $this->content->addFile(__DIR__.'/../../../../views/installStep2.php', $this); |
|
153 | + $this->template->toHtml(); |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * This action generates the TDBM instance, then the DAOs and Beans. |
|
158 | + * |
|
159 | + * @Action |
|
160 | + * |
|
161 | + * @param string $daonamespace |
|
162 | + * @param string $beannamespace |
|
163 | + * @param string $selfedit |
|
164 | + * |
|
165 | + * @throws \Mouf\MoufException |
|
166 | + */ |
|
167 | + public function generate($daonamespace, $beannamespace, /*$storeInUtc = 0,*/ $selfedit = 'false', $defaultPath = false, $storePath = '') |
|
168 | + { |
|
169 | + $this->selfedit = $selfedit; |
|
170 | + |
|
171 | + if ($selfedit == 'true') { |
|
172 | + $this->moufManager = MoufManager::getMoufManager(); |
|
173 | + } else { |
|
174 | + $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); |
|
175 | + } |
|
176 | + |
|
177 | + $doctrineCache = $this->moufManager->getInstanceDescriptor('defaultDoctrineCache'); |
|
178 | + |
|
179 | + $migratingFrom42 = false; |
|
180 | + if ($this->moufManager->has('tdbmService') && !$this->moufManager->has('tdbmConfiguration')) { |
|
181 | + $migratingFrom42 = true; |
|
182 | + } |
|
183 | + |
|
184 | + if ($this->moufManager->has('tdbmService') && $this->moufManager->getInstanceDescriptor('tdbmService')->getClassName() === 'Mouf\\Database\\TDBM\\TDBMService') { |
|
185 | + $this->migrateNamespaceTo50($this->moufManager); |
|
186 | + } |
|
187 | + |
|
188 | + $annotationParser = InstallUtils::getOrCreateInstance(AnnotationParser::class, AnnotationParser::class, $this->moufManager); |
|
189 | + $annotationParser->getConstructorArgumentProperty('annotations')->setValue([ |
|
190 | + 'UUID' => UUID::class, |
|
191 | + 'Autoincrement' => Autoincrement::class, |
|
192 | + 'Bean' => Bean::class |
|
193 | + ]); |
|
194 | + |
|
195 | + $namingStrategy = InstallUtils::getOrCreateInstance('namingStrategy', DefaultNamingStrategy::class, $this->moufManager); |
|
196 | + if ($migratingFrom42) { |
|
197 | + // Let's setup the naming strategy for compatibility |
|
198 | + $namingStrategy->getSetterProperty('setBeanPrefix')->setValue(''); |
|
199 | + $namingStrategy->getSetterProperty('setBeanSuffix')->setValue('Bean'); |
|
200 | + $namingStrategy->getSetterProperty('setBaseBeanPrefix')->setValue(''); |
|
201 | + $namingStrategy->getSetterProperty('setBaseBeanSuffix')->setValue('BaseBean'); |
|
202 | + $namingStrategy->getSetterProperty('setDaoPrefix')->setValue(''); |
|
203 | + $namingStrategy->getSetterProperty('setDaoSuffix')->setValue('Dao'); |
|
204 | + $namingStrategy->getSetterProperty('setBaseDaoPrefix')->setValue(''); |
|
205 | + $namingStrategy->getSetterProperty('setBaseDaoSuffix')->setValue('BaseDao'); |
|
206 | + } |
|
207 | + if ($namingStrategy->getClassName() === DefaultNamingStrategy::class) { |
|
208 | + $namingStrategy->getConstructorArgumentProperty('annotationParser')->setValue($this->moufManager->getInstanceDescriptor(AnnotationParser::class)); |
|
209 | + $namingStrategy->getConstructorArgumentProperty('schemaManager')->setOrigin('php')->setValue('return $container->get(\'dbalConnection\')->getSchemaManager();'); |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + if (!$this->moufManager->instanceExists('tdbmConfiguration')) { |
|
214 | + $moufListener = InstallUtils::getOrCreateInstance(MoufDiListener::class, MoufDiListener::class, $this->moufManager); |
|
215 | + |
|
216 | + $tdbmConfiguration = $this->moufManager->createInstance(MoufConfiguration::class)->setName('tdbmConfiguration'); |
|
217 | + $tdbmConfiguration->getConstructorArgumentProperty('connection')->setValue($this->moufManager->getInstanceDescriptor('dbalConnection')); |
|
218 | + $tdbmConfiguration->getConstructorArgumentProperty('cache')->setValue($doctrineCache); |
|
219 | + $tdbmConfiguration->getConstructorArgumentProperty('namingStrategy')->setValue($namingStrategy); |
|
220 | + $tdbmConfiguration->getProperty('daoFactoryInstanceName')->setValue('daoFactory'); |
|
221 | + $tdbmConfiguration->getConstructorArgumentProperty('generatorListeners')->setValue([$moufListener]); |
|
222 | + |
|
223 | + // Let's also delete the tdbmService if migrating versions <= 4.2 |
|
224 | + if ($migratingFrom42) { |
|
225 | + $this->moufManager->removeComponent('tdbmService'); |
|
226 | + } |
|
227 | + } else { |
|
228 | + $tdbmConfiguration = $this->moufManager->getInstanceDescriptor('tdbmConfiguration'); |
|
229 | + } |
|
230 | + |
|
231 | + if (!$this->moufManager->instanceExists('tdbmService')) { |
|
232 | + $tdbmService = $this->moufManager->createInstance('TheCodingMachine\\TDBM\\TDBMService')->setName('tdbmService'); |
|
233 | + $tdbmService->getConstructorArgumentProperty('configuration')->setValue($tdbmConfiguration); |
|
234 | + } |
|
235 | + |
|
236 | + // We declare our instance of the Symfony command as a Mouf instance |
|
237 | + $generateCommand = InstallUtils::getOrCreateInstance('generateCommand', GenerateCommand::class, $this->moufManager); |
|
238 | + $generateCommand->getConstructorArgumentProperty('configuration')->setValue($tdbmConfiguration); |
|
239 | + |
|
240 | + // We register that instance descriptor using "ConsoleUtils" |
|
241 | + $consoleUtils = new ConsoleUtils($this->moufManager); |
|
242 | + $consoleUtils->registerCommand($generateCommand); |
|
243 | + |
|
244 | + $this->moufManager->rewriteMouf(); |
|
245 | + |
|
246 | + TdbmController::generateDaos($this->moufManager, 'tdbmService', $daonamespace, $beannamespace, 'daoFactory', $selfedit, /*$storeInUtc,*/ $defaultPath, $storePath); |
|
247 | + |
|
248 | + InstallUtils::continueInstall($selfedit == 'true'); |
|
249 | + } |
|
250 | + |
|
251 | + protected $errorMsg; |
|
252 | + |
|
253 | + private function displayErrorMsg($msg) |
|
254 | + { |
|
255 | + $this->errorMsg = $msg; |
|
256 | + $this->content->addFile(__DIR__.'/../../../../views/installError.php', $this); |
|
257 | + $this->template->toHtml(); |
|
258 | + } |
|
259 | + |
|
260 | + /** |
|
261 | + * Migrate classes from old 4.x namespace (Mouf\Database\TDBM) to new 5.x namespace (TheCodingMachine\TDBM) |
|
262 | + * |
|
263 | + * @param MoufManager $moufManager |
|
264 | + */ |
|
265 | + private function migrateNamespaceTo50(MoufManager $moufManager) |
|
266 | + { |
|
267 | + $instanceList = $moufManager->getInstancesList(); |
|
268 | + |
|
269 | + $migratedClasses = [ |
|
270 | + 'Mouf\\Database\\TDBM\\Configuration' => 'TheCodingMachine\\TDBM\\Configuration', |
|
271 | + 'Mouf\\Database\\TDBM\\TDBMService' => 'TheCodingMachine\\TDBM\\TDBMService', |
|
272 | + 'Mouf\\Database\\TDBM\\Commands\\GenerateCommand' => 'TheCodingMachine\\TDBM\\Commands\\GenerateCommand', |
|
273 | + 'Mouf\\Database\\TDBM\\Utils\\DefaultNamingStrategy' => 'TheCodingMachine\\TDBM\\Utils\\DefaultNamingStrategy', |
|
274 | + ]; |
|
275 | + |
|
276 | + foreach ($instanceList as $instanceName => $className) { |
|
277 | + if (isset($migratedClasses[$className])) { |
|
278 | + $moufManager->alterClass($instanceName, $migratedClasses[$className]); |
|
279 | + } |
|
280 | + } |
|
281 | + } |
|
282 | 282 | } |