@@ -181,6 +181,9 @@  | 
                                                    ||
| 181 | 181 | |
| 182 | 182 | protected $errorMsg;  | 
                                                        
| 183 | 183 | |
| 184 | + /**  | 
                                                        |
| 185 | + * @param string $msg  | 
                                                        |
| 186 | + */  | 
                                                        |
| 184 | 187 | private function displayErrorMsg($msg)  | 
                                                        
| 185 | 188 |      { | 
                                                        
| 186 | 189 | $this->errorMsg = $msg;  | 
                                                        
@@ -38,271 +38,271 @@  | 
                                                    ||
| 38 | 38 | */  | 
                                                        
| 39 | 39 | class TdbmInstallController extends Controller  | 
                                                        
| 40 | 40 |  { | 
                                                        
| 41 | - /**  | 
                                                        |
| 42 | - * @var HtmlBlock  | 
                                                        |
| 43 | - */  | 
                                                        |
| 44 | - public $content;  | 
                                                        |
| 45 | -  | 
                                                        |
| 46 | - public $selfedit;  | 
                                                        |
| 47 | -  | 
                                                        |
| 48 | - /**  | 
                                                        |
| 49 | - * The active MoufManager to be edited/viewed.  | 
                                                        |
| 50 | - *  | 
                                                        |
| 51 | - * @var MoufManager  | 
                                                        |
| 52 | - */  | 
                                                        |
| 53 | - public $moufManager;  | 
                                                        |
| 54 | -  | 
                                                        |
| 55 | - /**  | 
                                                        |
| 56 | - * The template used by the main page for mouf.  | 
                                                        |
| 57 | - *  | 
                                                        |
| 58 | - * @Property  | 
                                                        |
| 59 | - * @Compulsory  | 
                                                        |
| 60 | - *  | 
                                                        |
| 61 | - * @var TemplateInterface  | 
                                                        |
| 62 | - */  | 
                                                        |
| 63 | - public $template;  | 
                                                        |
| 64 | -  | 
                                                        |
| 65 | - /**  | 
                                                        |
| 66 | - * Displays the first install screen.  | 
                                                        |
| 67 | - *  | 
                                                        |
| 68 | - * @Action  | 
                                                        |
| 69 | - * @Logged  | 
                                                        |
| 70 | - *  | 
                                                        |
| 71 | - * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only)  | 
                                                        |
| 72 | - */  | 
                                                        |
| 73 | - public function defaultAction($selfedit = 'false')  | 
                                                        |
| 74 | -    { | 
                                                        |
| 75 | - $this->selfedit = $selfedit;  | 
                                                        |
| 76 | -  | 
                                                        |
| 77 | -        if ($selfedit == 'true') { | 
                                                        |
| 78 | - $this->moufManager = MoufManager::getMoufManager();  | 
                                                        |
| 79 | -        } else { | 
                                                        |
| 80 | - $this->moufManager = MoufManager::getMoufManagerHiddenInstance();  | 
                                                        |
| 81 | - }  | 
                                                        |
| 82 | -  | 
                                                        |
| 83 | - $this->content->addFile(__DIR__.'/../../../../views/installStep1.php', $this);  | 
                                                        |
| 84 | - $this->template->toHtml();  | 
                                                        |
| 85 | - }  | 
                                                        |
| 86 | -  | 
                                                        |
| 87 | - /**  | 
                                                        |
| 88 | - * Skips the install process.  | 
                                                        |
| 89 | - *  | 
                                                        |
| 90 | - * @Action  | 
                                                        |
| 91 | - * @Logged  | 
                                                        |
| 92 | - *  | 
                                                        |
| 93 | - * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only)  | 
                                                        |
| 94 | - */  | 
                                                        |
| 95 | - public function skip($selfedit = 'false')  | 
                                                        |
| 96 | -    { | 
                                                        |
| 97 | - InstallUtils::continueInstall($selfedit == 'true');  | 
                                                        |
| 98 | - }  | 
                                                        |
| 99 | -  | 
                                                        |
| 100 | - protected $daoNamespace;  | 
                                                        |
| 101 | - protected $beanNamespace;  | 
                                                        |
| 102 | - protected $autoloadDetected;  | 
                                                        |
| 103 | - //protected $storeInUtc;  | 
                                                        |
| 104 | - protected $useCustomComposer = false;  | 
                                                        |
| 105 | - protected $composerFile;  | 
                                                        |
| 106 | -  | 
                                                        |
| 107 | - /**  | 
                                                        |
| 108 | - * Displays the second install screen.  | 
                                                        |
| 109 | - *  | 
                                                        |
| 110 | - * @Action  | 
                                                        |
| 111 | - * @Logged  | 
                                                        |
| 112 | - *  | 
                                                        |
| 113 | - * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only)  | 
                                                        |
| 114 | - */  | 
                                                        |
| 115 | - public function configure($selfedit = 'false')  | 
                                                        |
| 116 | -    { | 
                                                        |
| 117 | - $this->selfedit = $selfedit;  | 
                                                        |
| 118 | -  | 
                                                        |
| 119 | -        if ($selfedit == 'true') { | 
                                                        |
| 120 | - $this->moufManager = MoufManager::getMoufManager();  | 
                                                        |
| 121 | -        } else { | 
                                                        |
| 122 | - $this->moufManager = MoufManager::getMoufManagerHiddenInstance();  | 
                                                        |
| 123 | - }  | 
                                                        |
| 124 | -  | 
                                                        |
| 125 | - // Let's start by performing basic checks about the instances we assume to exist.  | 
                                                        |
| 126 | -        if (!$this->moufManager->instanceExists('dbalConnection')) { | 
                                                        |
| 127 | -            $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."); | 
                                                        |
| 128 | -  | 
                                                        |
| 129 | - return;  | 
                                                        |
| 130 | - }  | 
                                                        |
| 131 | -  | 
                                                        |
| 132 | -        if ($this->moufManager->has('tdbmConfiguration')) { | 
                                                        |
| 133 | -            $tdbmConfiguration = $this->moufManager->getInstanceDescriptor('tdbmConfiguration'); | 
                                                        |
| 134 | -  | 
                                                        |
| 135 | -            $this->beanNamespace = $tdbmConfiguration->getConstructorArgumentProperty('beanNamespace')->getValue(); | 
                                                        |
| 136 | -            $this->daoNamespace = $tdbmConfiguration->getConstructorArgumentProperty('daoNamespace')->getValue(); | 
                                                        |
| 137 | -        } else { | 
                                                        |
| 138 | - // Old TDBM 4.2 fallback  | 
                                                        |
| 139 | -            $this->daoNamespace = $this->moufManager->getVariable('tdbmDefaultDaoNamespace_tdbmService'); | 
                                                        |
| 140 | -            $this->beanNamespace = $this->moufManager->getVariable('tdbmDefaultBeanNamespace_tdbmService'); | 
                                                        |
| 141 | - }  | 
                                                        |
| 142 | -  | 
                                                        |
| 143 | -        if ($this->daoNamespace == null && $this->beanNamespace == null) { | 
                                                        |
| 144 | - $classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json');  | 
                                                        |
| 145 | -  | 
                                                        |
| 146 | - $autoloadNamespaces = $classNameMapper->getManagedNamespaces();  | 
                                                        |
| 147 | -            if ($autoloadNamespaces) { | 
                                                        |
| 148 | - $this->autoloadDetected = true;  | 
                                                        |
| 149 | - $rootNamespace = $autoloadNamespaces[0];  | 
                                                        |
| 150 | - $this->daoNamespace = $rootNamespace.'Dao';  | 
                                                        |
| 151 | - $this->beanNamespace = $rootNamespace.'Model';  | 
                                                        |
| 152 | -            } else { | 
                                                        |
| 153 | - $this->autoloadDetected = false;  | 
                                                        |
| 154 | - $this->daoNamespace = 'YourApplication\\Dao';  | 
                                                        |
| 155 | - $this->beanNamespace = 'YourApplication\\Model';  | 
                                                        |
| 156 | - }  | 
                                                        |
| 157 | -        } else { | 
                                                        |
| 158 | - $this->autoloadDetected = true;  | 
                                                        |
| 159 | - }  | 
                                                        |
| 160 | - $this->defaultPath = true;  | 
                                                        |
| 161 | - $this->storePath = '';  | 
                                                        |
| 162 | -  | 
                                                        |
| 163 | - $this->castDatesToDateTime = true;  | 
                                                        |
| 164 | -  | 
                                                        |
| 165 | - $this->content->addFile(__DIR__.'/../../../../views/installStep2.php', $this);  | 
                                                        |
| 166 | - $this->template->toHtml();  | 
                                                        |
| 167 | - }  | 
                                                        |
| 168 | -  | 
                                                        |
| 169 | - /**  | 
                                                        |
| 170 | - * This action generates the TDBM instance, then the DAOs and Beans.  | 
                                                        |
| 171 | - *  | 
                                                        |
| 172 | - * @Action  | 
                                                        |
| 173 | - *  | 
                                                        |
| 174 | - * @param string $daonamespace  | 
                                                        |
| 175 | - * @param string $beannamespace  | 
                                                        |
| 176 | - * @param string $selfedit  | 
                                                        |
| 177 | - *  | 
                                                        |
| 178 | - * @throws \Mouf\MoufException  | 
                                                        |
| 179 | - */  | 
                                                        |
| 180 | - public function generate($daonamespace, $beannamespace, /*$storeInUtc = 0,*/ $selfedit = 'false', $defaultPath = false, $storePath = '')  | 
                                                        |
| 181 | -    { | 
                                                        |
| 182 | - $this->selfedit = $selfedit;  | 
                                                        |
| 183 | -  | 
                                                        |
| 184 | -        if ($selfedit == 'true') { | 
                                                        |
| 185 | - $this->moufManager = MoufManager::getMoufManager();  | 
                                                        |
| 186 | -        } else { | 
                                                        |
| 187 | - $this->moufManager = MoufManager::getMoufManagerHiddenInstance();  | 
                                                        |
| 188 | - }  | 
                                                        |
| 189 | -  | 
                                                        |
| 190 | -        $doctrineCache = $this->moufManager->getInstanceDescriptor('defaultDoctrineCache'); | 
                                                        |
| 191 | -  | 
                                                        |
| 192 | - $migratingFrom42 = false;  | 
                                                        |
| 193 | -        if ($this->moufManager->has('tdbmService') && !$this->moufManager->has('tdbmConfiguration')) { | 
                                                        |
| 194 | - $migratingFrom42 = true;  | 
                                                        |
| 195 | - }  | 
                                                        |
| 196 | -  | 
                                                        |
| 197 | -        if ($this->moufManager->has('tdbmService') && $this->moufManager->getInstanceDescriptor('tdbmService')->getClassName() === 'Mouf\\Database\\TDBM\\TDBMService') { | 
                                                        |
| 198 | - $this->migrateNamespaceTo50($this->moufManager);  | 
                                                        |
| 199 | - }  | 
                                                        |
| 200 | -  | 
                                                        |
| 201 | - $annotationParser = InstallUtils::getOrCreateInstance(AnnotationParser::class, AnnotationParser::class, $this->moufManager);  | 
                                                        |
| 202 | -        $annotationParser->getConstructorArgumentProperty('annotations')->setValue([ | 
                                                        |
| 203 | - 'UUID' => UUID::class,  | 
                                                        |
| 204 | - 'Autoincrement' => Autoincrement::class,  | 
                                                        |
| 205 | - 'Bean' => Bean::class,  | 
                                                        |
| 206 | - 'ProtectedGetter' => ProtectedGetter::class,  | 
                                                        |
| 207 | - 'ProtectedSetter' => ProtectedSetter::class,  | 
                                                        |
| 208 | - 'ProtectedOneToMany' => ProtectedOneToMany::class,  | 
                                                        |
| 209 | - 'JsonKey' => JsonKey::class,  | 
                                                        |
| 210 | - 'JsonIgnore' => JsonIgnore::class,  | 
                                                        |
| 211 | - 'JsonInclude' => JsonInclude::class,  | 
                                                        |
| 212 | - 'JsonRecursive' => JsonRecursive::class,  | 
                                                        |
| 213 | - 'JsonCollection' => JsonCollection::class,  | 
                                                        |
| 214 | - 'JsonFormat' => JsonFormat::class,  | 
                                                        |
| 215 | - 'AddInterface' => AddInterface::class,  | 
                                                        |
| 216 | - 'AddInterfaceOnDao' => AddInterfaceOnDao::class,  | 
                                                        |
| 217 | - 'AddTrait' => AddTrait::class,  | 
                                                        |
| 218 | - 'AddTraitOnDao' => AddTraitOnDao::class,  | 
                                                        |
| 219 | - ]);  | 
                                                        |
| 220 | -  | 
                                                        |
| 221 | -        $namingStrategy = InstallUtils::getOrCreateInstance('namingStrategy', DefaultNamingStrategy::class, $this->moufManager); | 
                                                        |
| 222 | -        if ($migratingFrom42) { | 
                                                        |
| 223 | - // Let's setup the naming strategy for compatibility  | 
                                                        |
| 224 | -            $namingStrategy->getSetterProperty('setBeanPrefix')->setValue(''); | 
                                                        |
| 225 | -            $namingStrategy->getSetterProperty('setBeanSuffix')->setValue('Bean'); | 
                                                        |
| 226 | -            $namingStrategy->getSetterProperty('setBaseBeanPrefix')->setValue(''); | 
                                                        |
| 227 | -            $namingStrategy->getSetterProperty('setBaseBeanSuffix')->setValue('BaseBean'); | 
                                                        |
| 228 | -            $namingStrategy->getSetterProperty('setDaoPrefix')->setValue(''); | 
                                                        |
| 229 | -            $namingStrategy->getSetterProperty('setDaoSuffix')->setValue('Dao'); | 
                                                        |
| 230 | -            $namingStrategy->getSetterProperty('setBaseDaoPrefix')->setValue(''); | 
                                                        |
| 231 | -            $namingStrategy->getSetterProperty('setBaseDaoSuffix')->setValue('BaseDao'); | 
                                                        |
| 232 | - }  | 
                                                        |
| 233 | -        if ($namingStrategy->getClassName() === DefaultNamingStrategy::class) { | 
                                                        |
| 234 | -            $namingStrategy->getConstructorArgumentProperty('annotationParser')->setValue($this->moufManager->getInstanceDescriptor(AnnotationParser::class)); | 
                                                        |
| 235 | -            $namingStrategy->getConstructorArgumentProperty('schemaManager')->setOrigin('php')->setValue('return $container->get(\'dbalConnection\')->getSchemaManager();'); | 
                                                        |
| 236 | - }  | 
                                                        |
| 237 | -  | 
                                                        |
| 238 | -  | 
                                                        |
| 239 | -        if (!$this->moufManager->instanceExists('tdbmConfiguration')) { | 
                                                        |
| 240 | - $moufListener = InstallUtils::getOrCreateInstance(MoufDiListener::class, MoufDiListener::class, $this->moufManager);  | 
                                                        |
| 241 | -  | 
                                                        |
| 242 | -            $tdbmConfiguration = $this->moufManager->createInstance(MoufConfiguration::class)->setName('tdbmConfiguration'); | 
                                                        |
| 243 | -            $tdbmConfiguration->getConstructorArgumentProperty('connection')->setValue($this->moufManager->getInstanceDescriptor('dbalConnection')); | 
                                                        |
| 244 | -            $tdbmConfiguration->getConstructorArgumentProperty('cache')->setValue($doctrineCache); | 
                                                        |
| 245 | -            $tdbmConfiguration->getConstructorArgumentProperty('namingStrategy')->setValue($namingStrategy); | 
                                                        |
| 246 | -            $tdbmConfiguration->getProperty('daoFactoryInstanceName')->setValue('daoFactory'); | 
                                                        |
| 247 | -            $tdbmConfiguration->getConstructorArgumentProperty('generatorListeners')->setValue([$moufListener]); | 
                                                        |
| 248 | -  | 
                                                        |
| 249 | - // Let's also delete the tdbmService if migrating versions <= 4.2  | 
                                                        |
| 250 | -            if ($migratingFrom42) { | 
                                                        |
| 251 | -                $this->moufManager->removeComponent('tdbmService'); | 
                                                        |
| 252 | - }  | 
                                                        |
| 253 | -        } else { | 
                                                        |
| 254 | -            $tdbmConfiguration = $this->moufManager->getInstanceDescriptor('tdbmConfiguration'); | 
                                                        |
| 255 | - }  | 
                                                        |
| 256 | -  | 
                                                        |
| 257 | -        if (!$this->moufManager->instanceExists('tdbmService')) { | 
                                                        |
| 258 | -            $tdbmService = $this->moufManager->createInstance('TheCodingMachine\\TDBM\\TDBMService')->setName('tdbmService'); | 
                                                        |
| 259 | -            $tdbmService->getConstructorArgumentProperty('configuration')->setValue($tdbmConfiguration); | 
                                                        |
| 260 | - }  | 
                                                        |
| 261 | -  | 
                                                        |
| 262 | - // We declare our instance of the Symfony command as a Mouf instance  | 
                                                        |
| 263 | -        $generateCommand = InstallUtils::getOrCreateInstance('generateCommand', GenerateCommand::class, $this->moufManager); | 
                                                        |
| 264 | -        $generateCommand->getConstructorArgumentProperty('configuration')->setValue($tdbmConfiguration); | 
                                                        |
| 265 | -  | 
                                                        |
| 266 | - // We register that instance descriptor using "ConsoleUtils"  | 
                                                        |
| 267 | - $consoleUtils = new ConsoleUtils($this->moufManager);  | 
                                                        |
| 268 | - $consoleUtils->registerCommand($generateCommand);  | 
                                                        |
| 269 | -  | 
                                                        |
| 270 | - $this->moufManager->rewriteMouf();  | 
                                                        |
| 271 | -  | 
                                                        |
| 272 | - TdbmController::generateDaos($this->moufManager, 'tdbmService', $daonamespace, $beannamespace, 'daoFactory', $selfedit, /*$storeInUtc,*/ $defaultPath, $storePath);  | 
                                                        |
| 273 | -  | 
                                                        |
| 274 | - InstallUtils::continueInstall($selfedit == 'true');  | 
                                                        |
| 275 | - }  | 
                                                        |
| 276 | -  | 
                                                        |
| 277 | - protected $errorMsg;  | 
                                                        |
| 278 | -  | 
                                                        |
| 279 | - private function displayErrorMsg($msg)  | 
                                                        |
| 280 | -    { | 
                                                        |
| 281 | - $this->errorMsg = $msg;  | 
                                                        |
| 282 | - $this->content->addFile(__DIR__.'/../../../../views/installError.php', $this);  | 
                                                        |
| 283 | - $this->template->toHtml();  | 
                                                        |
| 284 | - }  | 
                                                        |
| 285 | -  | 
                                                        |
| 286 | - /**  | 
                                                        |
| 287 | - * Migrate classes from old 4.x namespace (Mouf\Database\TDBM) to new 5.x namespace (TheCodingMachine\TDBM)  | 
                                                        |
| 288 | - *  | 
                                                        |
| 289 | - * @param MoufManager $moufManager  | 
                                                        |
| 290 | - */  | 
                                                        |
| 291 | - private function migrateNamespaceTo50(MoufManager $moufManager)  | 
                                                        |
| 292 | -    { | 
                                                        |
| 293 | - $instanceList = $moufManager->getInstancesList();  | 
                                                        |
| 294 | -  | 
                                                        |
| 295 | - $migratedClasses = [  | 
                                                        |
| 296 | - 'Mouf\\Database\\TDBM\\Configuration' => 'TheCodingMachine\\TDBM\\Configuration',  | 
                                                        |
| 297 | - 'Mouf\\Database\\TDBM\\TDBMService' => 'TheCodingMachine\\TDBM\\TDBMService',  | 
                                                        |
| 298 | - 'Mouf\\Database\\TDBM\\Commands\\GenerateCommand' => 'TheCodingMachine\\TDBM\\Commands\\GenerateCommand',  | 
                                                        |
| 299 | - 'Mouf\\Database\\TDBM\\Utils\\DefaultNamingStrategy' => 'TheCodingMachine\\TDBM\\Utils\\DefaultNamingStrategy',  | 
                                                        |
| 300 | - ];  | 
                                                        |
| 301 | -  | 
                                                        |
| 302 | -        foreach ($instanceList as $instanceName => $className) { | 
                                                        |
| 303 | -            if (isset($migratedClasses[$className])) { | 
                                                        |
| 304 | - $moufManager->alterClass($instanceName, $migratedClasses[$className]);  | 
                                                        |
| 305 | - }  | 
                                                        |
| 306 | - }  | 
                                                        |
| 307 | - }  | 
                                                        |
| 41 | + /**  | 
                                                        |
| 42 | + * @var HtmlBlock  | 
                                                        |
| 43 | + */  | 
                                                        |
| 44 | + public $content;  | 
                                                        |
| 45 | +  | 
                                                        |
| 46 | + public $selfedit;  | 
                                                        |
| 47 | +  | 
                                                        |
| 48 | + /**  | 
                                                        |
| 49 | + * The active MoufManager to be edited/viewed.  | 
                                                        |
| 50 | + *  | 
                                                        |
| 51 | + * @var MoufManager  | 
                                                        |
| 52 | + */  | 
                                                        |
| 53 | + public $moufManager;  | 
                                                        |
| 54 | +  | 
                                                        |
| 55 | + /**  | 
                                                        |
| 56 | + * The template used by the main page for mouf.  | 
                                                        |
| 57 | + *  | 
                                                        |
| 58 | + * @Property  | 
                                                        |
| 59 | + * @Compulsory  | 
                                                        |
| 60 | + *  | 
                                                        |
| 61 | + * @var TemplateInterface  | 
                                                        |
| 62 | + */  | 
                                                        |
| 63 | + public $template;  | 
                                                        |
| 64 | +  | 
                                                        |
| 65 | + /**  | 
                                                        |
| 66 | + * Displays the first install screen.  | 
                                                        |
| 67 | + *  | 
                                                        |
| 68 | + * @Action  | 
                                                        |
| 69 | + * @Logged  | 
                                                        |
| 70 | + *  | 
                                                        |
| 71 | + * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only)  | 
                                                        |
| 72 | + */  | 
                                                        |
| 73 | + public function defaultAction($selfedit = 'false')  | 
                                                        |
| 74 | +	{ | 
                                                        |
| 75 | + $this->selfedit = $selfedit;  | 
                                                        |
| 76 | +  | 
                                                        |
| 77 | +		if ($selfedit == 'true') { | 
                                                        |
| 78 | + $this->moufManager = MoufManager::getMoufManager();  | 
                                                        |
| 79 | +		} else { | 
                                                        |
| 80 | + $this->moufManager = MoufManager::getMoufManagerHiddenInstance();  | 
                                                        |
| 81 | + }  | 
                                                        |
| 82 | +  | 
                                                        |
| 83 | + $this->content->addFile(__DIR__.'/../../../../views/installStep1.php', $this);  | 
                                                        |
| 84 | + $this->template->toHtml();  | 
                                                        |
| 85 | + }  | 
                                                        |
| 86 | +  | 
                                                        |
| 87 | + /**  | 
                                                        |
| 88 | + * Skips the install process.  | 
                                                        |
| 89 | + *  | 
                                                        |
| 90 | + * @Action  | 
                                                        |
| 91 | + * @Logged  | 
                                                        |
| 92 | + *  | 
                                                        |
| 93 | + * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only)  | 
                                                        |
| 94 | + */  | 
                                                        |
| 95 | + public function skip($selfedit = 'false')  | 
                                                        |
| 96 | +	{ | 
                                                        |
| 97 | + InstallUtils::continueInstall($selfedit == 'true');  | 
                                                        |
| 98 | + }  | 
                                                        |
| 99 | +  | 
                                                        |
| 100 | + protected $daoNamespace;  | 
                                                        |
| 101 | + protected $beanNamespace;  | 
                                                        |
| 102 | + protected $autoloadDetected;  | 
                                                        |
| 103 | + //protected $storeInUtc;  | 
                                                        |
| 104 | + protected $useCustomComposer = false;  | 
                                                        |
| 105 | + protected $composerFile;  | 
                                                        |
| 106 | +  | 
                                                        |
| 107 | + /**  | 
                                                        |
| 108 | + * Displays the second install screen.  | 
                                                        |
| 109 | + *  | 
                                                        |
| 110 | + * @Action  | 
                                                        |
| 111 | + * @Logged  | 
                                                        |
| 112 | + *  | 
                                                        |
| 113 | + * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only)  | 
                                                        |
| 114 | + */  | 
                                                        |
| 115 | + public function configure($selfedit = 'false')  | 
                                                        |
| 116 | +	{ | 
                                                        |
| 117 | + $this->selfedit = $selfedit;  | 
                                                        |
| 118 | +  | 
                                                        |
| 119 | +		if ($selfedit == 'true') { | 
                                                        |
| 120 | + $this->moufManager = MoufManager::getMoufManager();  | 
                                                        |
| 121 | +		} else { | 
                                                        |
| 122 | + $this->moufManager = MoufManager::getMoufManagerHiddenInstance();  | 
                                                        |
| 123 | + }  | 
                                                        |
| 124 | +  | 
                                                        |
| 125 | + // Let's start by performing basic checks about the instances we assume to exist.  | 
                                                        |
| 126 | +		if (!$this->moufManager->instanceExists('dbalConnection')) { | 
                                                        |
| 127 | +			$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."); | 
                                                        |
| 128 | +  | 
                                                        |
| 129 | + return;  | 
                                                        |
| 130 | + }  | 
                                                        |
| 131 | +  | 
                                                        |
| 132 | +		if ($this->moufManager->has('tdbmConfiguration')) { | 
                                                        |
| 133 | +			$tdbmConfiguration = $this->moufManager->getInstanceDescriptor('tdbmConfiguration'); | 
                                                        |
| 134 | +  | 
                                                        |
| 135 | +			$this->beanNamespace = $tdbmConfiguration->getConstructorArgumentProperty('beanNamespace')->getValue(); | 
                                                        |
| 136 | +			$this->daoNamespace = $tdbmConfiguration->getConstructorArgumentProperty('daoNamespace')->getValue(); | 
                                                        |
| 137 | +		} else { | 
                                                        |
| 138 | + // Old TDBM 4.2 fallback  | 
                                                        |
| 139 | +			$this->daoNamespace = $this->moufManager->getVariable('tdbmDefaultDaoNamespace_tdbmService'); | 
                                                        |
| 140 | +			$this->beanNamespace = $this->moufManager->getVariable('tdbmDefaultBeanNamespace_tdbmService'); | 
                                                        |
| 141 | + }  | 
                                                        |
| 142 | +  | 
                                                        |
| 143 | +		if ($this->daoNamespace == null && $this->beanNamespace == null) { | 
                                                        |
| 144 | + $classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json');  | 
                                                        |
| 145 | +  | 
                                                        |
| 146 | + $autoloadNamespaces = $classNameMapper->getManagedNamespaces();  | 
                                                        |
| 147 | +			if ($autoloadNamespaces) { | 
                                                        |
| 148 | + $this->autoloadDetected = true;  | 
                                                        |
| 149 | + $rootNamespace = $autoloadNamespaces[0];  | 
                                                        |
| 150 | + $this->daoNamespace = $rootNamespace.'Dao';  | 
                                                        |
| 151 | + $this->beanNamespace = $rootNamespace.'Model';  | 
                                                        |
| 152 | +			} else { | 
                                                        |
| 153 | + $this->autoloadDetected = false;  | 
                                                        |
| 154 | + $this->daoNamespace = 'YourApplication\\Dao';  | 
                                                        |
| 155 | + $this->beanNamespace = 'YourApplication\\Model';  | 
                                                        |
| 156 | + }  | 
                                                        |
| 157 | +		} else { | 
                                                        |
| 158 | + $this->autoloadDetected = true;  | 
                                                        |
| 159 | + }  | 
                                                        |
| 160 | + $this->defaultPath = true;  | 
                                                        |
| 161 | + $this->storePath = '';  | 
                                                        |
| 162 | +  | 
                                                        |
| 163 | + $this->castDatesToDateTime = true;  | 
                                                        |
| 164 | +  | 
                                                        |
| 165 | + $this->content->addFile(__DIR__.'/../../../../views/installStep2.php', $this);  | 
                                                        |
| 166 | + $this->template->toHtml();  | 
                                                        |
| 167 | + }  | 
                                                        |
| 168 | +  | 
                                                        |
| 169 | + /**  | 
                                                        |
| 170 | + * This action generates the TDBM instance, then the DAOs and Beans.  | 
                                                        |
| 171 | + *  | 
                                                        |
| 172 | + * @Action  | 
                                                        |
| 173 | + *  | 
                                                        |
| 174 | + * @param string $daonamespace  | 
                                                        |
| 175 | + * @param string $beannamespace  | 
                                                        |
| 176 | + * @param string $selfedit  | 
                                                        |
| 177 | + *  | 
                                                        |
| 178 | + * @throws \Mouf\MoufException  | 
                                                        |
| 179 | + */  | 
                                                        |
| 180 | + public function generate($daonamespace, $beannamespace, /*$storeInUtc = 0,*/ $selfedit = 'false', $defaultPath = false, $storePath = '')  | 
                                                        |
| 181 | +	{ | 
                                                        |
| 182 | + $this->selfedit = $selfedit;  | 
                                                        |
| 183 | +  | 
                                                        |
| 184 | +		if ($selfedit == 'true') { | 
                                                        |
| 185 | + $this->moufManager = MoufManager::getMoufManager();  | 
                                                        |
| 186 | +		} else { | 
                                                        |
| 187 | + $this->moufManager = MoufManager::getMoufManagerHiddenInstance();  | 
                                                        |
| 188 | + }  | 
                                                        |
| 189 | +  | 
                                                        |
| 190 | +		$doctrineCache = $this->moufManager->getInstanceDescriptor('defaultDoctrineCache'); | 
                                                        |
| 191 | +  | 
                                                        |
| 192 | + $migratingFrom42 = false;  | 
                                                        |
| 193 | +		if ($this->moufManager->has('tdbmService') && !$this->moufManager->has('tdbmConfiguration')) { | 
                                                        |
| 194 | + $migratingFrom42 = true;  | 
                                                        |
| 195 | + }  | 
                                                        |
| 196 | +  | 
                                                        |
| 197 | +		if ($this->moufManager->has('tdbmService') && $this->moufManager->getInstanceDescriptor('tdbmService')->getClassName() === 'Mouf\\Database\\TDBM\\TDBMService') { | 
                                                        |
| 198 | + $this->migrateNamespaceTo50($this->moufManager);  | 
                                                        |
| 199 | + }  | 
                                                        |
| 200 | +  | 
                                                        |
| 201 | + $annotationParser = InstallUtils::getOrCreateInstance(AnnotationParser::class, AnnotationParser::class, $this->moufManager);  | 
                                                        |
| 202 | +		$annotationParser->getConstructorArgumentProperty('annotations')->setValue([ | 
                                                        |
| 203 | + 'UUID' => UUID::class,  | 
                                                        |
| 204 | + 'Autoincrement' => Autoincrement::class,  | 
                                                        |
| 205 | + 'Bean' => Bean::class,  | 
                                                        |
| 206 | + 'ProtectedGetter' => ProtectedGetter::class,  | 
                                                        |
| 207 | + 'ProtectedSetter' => ProtectedSetter::class,  | 
                                                        |
| 208 | + 'ProtectedOneToMany' => ProtectedOneToMany::class,  | 
                                                        |
| 209 | + 'JsonKey' => JsonKey::class,  | 
                                                        |
| 210 | + 'JsonIgnore' => JsonIgnore::class,  | 
                                                        |
| 211 | + 'JsonInclude' => JsonInclude::class,  | 
                                                        |
| 212 | + 'JsonRecursive' => JsonRecursive::class,  | 
                                                        |
| 213 | + 'JsonCollection' => JsonCollection::class,  | 
                                                        |
| 214 | + 'JsonFormat' => JsonFormat::class,  | 
                                                        |
| 215 | + 'AddInterface' => AddInterface::class,  | 
                                                        |
| 216 | + 'AddInterfaceOnDao' => AddInterfaceOnDao::class,  | 
                                                        |
| 217 | + 'AddTrait' => AddTrait::class,  | 
                                                        |
| 218 | + 'AddTraitOnDao' => AddTraitOnDao::class,  | 
                                                        |
| 219 | + ]);  | 
                                                        |
| 220 | +  | 
                                                        |
| 221 | +		$namingStrategy = InstallUtils::getOrCreateInstance('namingStrategy', DefaultNamingStrategy::class, $this->moufManager); | 
                                                        |
| 222 | +		if ($migratingFrom42) { | 
                                                        |
| 223 | + // Let's setup the naming strategy for compatibility  | 
                                                        |
| 224 | +			$namingStrategy->getSetterProperty('setBeanPrefix')->setValue(''); | 
                                                        |
| 225 | +			$namingStrategy->getSetterProperty('setBeanSuffix')->setValue('Bean'); | 
                                                        |
| 226 | +			$namingStrategy->getSetterProperty('setBaseBeanPrefix')->setValue(''); | 
                                                        |
| 227 | +			$namingStrategy->getSetterProperty('setBaseBeanSuffix')->setValue('BaseBean'); | 
                                                        |
| 228 | +			$namingStrategy->getSetterProperty('setDaoPrefix')->setValue(''); | 
                                                        |
| 229 | +			$namingStrategy->getSetterProperty('setDaoSuffix')->setValue('Dao'); | 
                                                        |
| 230 | +			$namingStrategy->getSetterProperty('setBaseDaoPrefix')->setValue(''); | 
                                                        |
| 231 | +			$namingStrategy->getSetterProperty('setBaseDaoSuffix')->setValue('BaseDao'); | 
                                                        |
| 232 | + }  | 
                                                        |
| 233 | +		if ($namingStrategy->getClassName() === DefaultNamingStrategy::class) { | 
                                                        |
| 234 | +			$namingStrategy->getConstructorArgumentProperty('annotationParser')->setValue($this->moufManager->getInstanceDescriptor(AnnotationParser::class)); | 
                                                        |
| 235 | +			$namingStrategy->getConstructorArgumentProperty('schemaManager')->setOrigin('php')->setValue('return $container->get(\'dbalConnection\')->getSchemaManager();'); | 
                                                        |
| 236 | + }  | 
                                                        |
| 237 | +  | 
                                                        |
| 238 | +  | 
                                                        |
| 239 | +		if (!$this->moufManager->instanceExists('tdbmConfiguration')) { | 
                                                        |
| 240 | + $moufListener = InstallUtils::getOrCreateInstance(MoufDiListener::class, MoufDiListener::class, $this->moufManager);  | 
                                                        |
| 241 | +  | 
                                                        |
| 242 | +			$tdbmConfiguration = $this->moufManager->createInstance(MoufConfiguration::class)->setName('tdbmConfiguration'); | 
                                                        |
| 243 | +			$tdbmConfiguration->getConstructorArgumentProperty('connection')->setValue($this->moufManager->getInstanceDescriptor('dbalConnection')); | 
                                                        |
| 244 | +			$tdbmConfiguration->getConstructorArgumentProperty('cache')->setValue($doctrineCache); | 
                                                        |
| 245 | +			$tdbmConfiguration->getConstructorArgumentProperty('namingStrategy')->setValue($namingStrategy); | 
                                                        |
| 246 | +			$tdbmConfiguration->getProperty('daoFactoryInstanceName')->setValue('daoFactory'); | 
                                                        |
| 247 | +			$tdbmConfiguration->getConstructorArgumentProperty('generatorListeners')->setValue([$moufListener]); | 
                                                        |
| 248 | +  | 
                                                        |
| 249 | + // Let's also delete the tdbmService if migrating versions <= 4.2  | 
                                                        |
| 250 | +			if ($migratingFrom42) { | 
                                                        |
| 251 | +				$this->moufManager->removeComponent('tdbmService'); | 
                                                        |
| 252 | + }  | 
                                                        |
| 253 | +		} else { | 
                                                        |
| 254 | +			$tdbmConfiguration = $this->moufManager->getInstanceDescriptor('tdbmConfiguration'); | 
                                                        |
| 255 | + }  | 
                                                        |
| 256 | +  | 
                                                        |
| 257 | +		if (!$this->moufManager->instanceExists('tdbmService')) { | 
                                                        |
| 258 | +			$tdbmService = $this->moufManager->createInstance('TheCodingMachine\\TDBM\\TDBMService')->setName('tdbmService'); | 
                                                        |
| 259 | +			$tdbmService->getConstructorArgumentProperty('configuration')->setValue($tdbmConfiguration); | 
                                                        |
| 260 | + }  | 
                                                        |
| 261 | +  | 
                                                        |
| 262 | + // We declare our instance of the Symfony command as a Mouf instance  | 
                                                        |
| 263 | +		$generateCommand = InstallUtils::getOrCreateInstance('generateCommand', GenerateCommand::class, $this->moufManager); | 
                                                        |
| 264 | +		$generateCommand->getConstructorArgumentProperty('configuration')->setValue($tdbmConfiguration); | 
                                                        |
| 265 | +  | 
                                                        |
| 266 | + // We register that instance descriptor using "ConsoleUtils"  | 
                                                        |
| 267 | + $consoleUtils = new ConsoleUtils($this->moufManager);  | 
                                                        |
| 268 | + $consoleUtils->registerCommand($generateCommand);  | 
                                                        |
| 269 | +  | 
                                                        |
| 270 | + $this->moufManager->rewriteMouf();  | 
                                                        |
| 271 | +  | 
                                                        |
| 272 | + TdbmController::generateDaos($this->moufManager, 'tdbmService', $daonamespace, $beannamespace, 'daoFactory', $selfedit, /*$storeInUtc,*/ $defaultPath, $storePath);  | 
                                                        |
| 273 | +  | 
                                                        |
| 274 | + InstallUtils::continueInstall($selfedit == 'true');  | 
                                                        |
| 275 | + }  | 
                                                        |
| 276 | +  | 
                                                        |
| 277 | + protected $errorMsg;  | 
                                                        |
| 278 | +  | 
                                                        |
| 279 | + private function displayErrorMsg($msg)  | 
                                                        |
| 280 | +	{ | 
                                                        |
| 281 | + $this->errorMsg = $msg;  | 
                                                        |
| 282 | + $this->content->addFile(__DIR__.'/../../../../views/installError.php', $this);  | 
                                                        |
| 283 | + $this->template->toHtml();  | 
                                                        |
| 284 | + }  | 
                                                        |
| 285 | +  | 
                                                        |
| 286 | + /**  | 
                                                        |
| 287 | + * Migrate classes from old 4.x namespace (Mouf\Database\TDBM) to new 5.x namespace (TheCodingMachine\TDBM)  | 
                                                        |
| 288 | + *  | 
                                                        |
| 289 | + * @param MoufManager $moufManager  | 
                                                        |
| 290 | + */  | 
                                                        |
| 291 | + private function migrateNamespaceTo50(MoufManager $moufManager)  | 
                                                        |
| 292 | +	{ | 
                                                        |
| 293 | + $instanceList = $moufManager->getInstancesList();  | 
                                                        |
| 294 | +  | 
                                                        |
| 295 | + $migratedClasses = [  | 
                                                        |
| 296 | + 'Mouf\\Database\\TDBM\\Configuration' => 'TheCodingMachine\\TDBM\\Configuration',  | 
                                                        |
| 297 | + 'Mouf\\Database\\TDBM\\TDBMService' => 'TheCodingMachine\\TDBM\\TDBMService',  | 
                                                        |
| 298 | + 'Mouf\\Database\\TDBM\\Commands\\GenerateCommand' => 'TheCodingMachine\\TDBM\\Commands\\GenerateCommand',  | 
                                                        |
| 299 | + 'Mouf\\Database\\TDBM\\Utils\\DefaultNamingStrategy' => 'TheCodingMachine\\TDBM\\Utils\\DefaultNamingStrategy',  | 
                                                        |
| 300 | + ];  | 
                                                        |
| 301 | +  | 
                                                        |
| 302 | +		foreach ($instanceList as $instanceName => $className) { | 
                                                        |
| 303 | +			if (isset($migratedClasses[$className])) { | 
                                                        |
| 304 | + $moufManager->alterClass($instanceName, $migratedClasses[$className]);  | 
                                                        |
| 305 | + }  | 
                                                        |
| 306 | + }  | 
                                                        |
| 307 | + }  | 
                                                        |
| 308 | 308 | }  | 
                                                        
@@ -8,7 +8,7 @@  | 
                                                    ||
| 8 | 8 | <input type="hidden" id="selfedit" name="selfedit" value="<?php echo plainstring_to_htmlprotected($this->selfedit) ?>" />  | 
                                                        
| 9 | 9 | |
| 10 | 10 |  <?php if (!$this->autoloadDetected) { | 
                                                        
| 11 | - ?>  | 
                                                        |
| 11 | + ?>  | 
                                                        |
| 12 | 12 | <div class="alert">Warning! TDBM could not detect the autoload section of your composer.json file.  | 
                                                        
| 13 | 13 | Unless you are developing your own autoload system, you should configure <strong>composer.json</strong> to <a href="http://getcomposer.org/doc/01-basic-usage.md#autoloading" target="_blank">define a source directory and a root namespace using PSR-0</a>.</div>  | 
                                                        
| 14 | 14 | <?php  | 
                                                        
@@ -17,21 +17,21 @@  | 
                                                    ||
| 17 | 17 | */  | 
                                                        
| 18 | 18 | class MoufConfiguration extends Configuration  | 
                                                        
| 19 | 19 |  { | 
                                                        
| 20 | - private $daoFactoryInstanceName = 'daoFactory';  | 
                                                        |
| 20 | + private $daoFactoryInstanceName = 'daoFactory';  | 
                                                        |
| 21 | 21 | |
| 22 | - /**  | 
                                                        |
| 23 | - * @return string  | 
                                                        |
| 24 | - */  | 
                                                        |
| 25 | - public function getDaoFactoryInstanceName() : string  | 
                                                        |
| 26 | -    { | 
                                                        |
| 27 | - return $this->daoFactoryInstanceName;  | 
                                                        |
| 28 | - }  | 
                                                        |
| 22 | + /**  | 
                                                        |
| 23 | + * @return string  | 
                                                        |
| 24 | + */  | 
                                                        |
| 25 | + public function getDaoFactoryInstanceName() : string  | 
                                                        |
| 26 | +	{ | 
                                                        |
| 27 | + return $this->daoFactoryInstanceName;  | 
                                                        |
| 28 | + }  | 
                                                        |
| 29 | 29 | |
| 30 | - /**  | 
                                                        |
| 31 | - * @param string $daoFactoryInstanceName  | 
                                                        |
| 32 | - */  | 
                                                        |
| 33 | - public function setDaoFactoryInstanceName(string $daoFactoryInstanceName)  | 
                                                        |
| 34 | -    { | 
                                                        |
| 35 | - $this->daoFactoryInstanceName = $daoFactoryInstanceName;  | 
                                                        |
| 36 | - }  | 
                                                        |
| 30 | + /**  | 
                                                        |
| 31 | + * @param string $daoFactoryInstanceName  | 
                                                        |
| 32 | + */  | 
                                                        |
| 33 | + public function setDaoFactoryInstanceName(string $daoFactoryInstanceName)  | 
                                                        |
| 34 | +	{ | 
                                                        |
| 35 | + $this->daoFactoryInstanceName = $daoFactoryInstanceName;  | 
                                                        |
| 36 | + }  | 
                                                        |
| 37 | 37 | }  | 
                                                        
@@ -8,7 +8,7 @@  | 
                                                    ||
| 8 | 8 | <input type="hidden" id="selfedit" name="selfedit" value="<?php echo plainstring_to_htmlprotected($this->selfedit) ?>" />  | 
                                                        
| 9 | 9 | |
| 10 | 10 |  <?php if (!$this->autoloadDetected) { | 
                                                        
| 11 | - ?>  | 
                                                        |
| 11 | + ?>  | 
                                                        |
| 12 | 12 | <div class="alert">Warning! TDBM could not detect the autoload section of your composer.json file.  | 
                                                        
| 13 | 13 | Unless you are developing your own autoload system, you should configure <strong>composer.json</strong> to <a href="http://getcomposer.org/doc/01-basic-usage.md#autoloading" target="_blank">define a source directory and a root namespace using PSR-0</a>.</div>  | 
                                                        
| 14 | 14 | <?php  | 
                                                        
@@ -82,7 +82,7 @@ discard block  | 
                                                    ||
| 82 | 82 | * @Action  | 
                                                        
| 83 | 83 | *  | 
                                                        
| 84 | 84 | * @param string $name  | 
                                                        
| 85 | - * @param bool $selfedit  | 
                                                        |
| 85 | + * @param string|boolean $selfedit  | 
                                                        |
| 86 | 86 | */  | 
                                                        
| 87 | 87 | public function generate($name, $daonamespace, $beannamespace, $daofactoryinstancename, /*$storeInUtc = 0,*/ $selfedit = 'false', $useCustomComposer = false, $composerFile = '')  | 
                                                        
| 88 | 88 |      { | 
                                                        
@@ -102,6 +102,8 @@ discard block  | 
                                                    ||
| 102 | 102 | * @param string $daonamespace  | 
                                                        
| 103 | 103 | * @param string $beannamespace  | 
                                                        
| 104 | 104 | * @param string $selfedit  | 
                                                        
| 105 | + * @param boolean $useCustomComposer  | 
                                                        |
| 106 | + * @param string $composerFile  | 
                                                        |
| 105 | 107 | *  | 
                                                        
| 106 | 108 | * @throws \Mouf\MoufException  | 
                                                        
| 107 | 109 | */  | 
                                                        
@@ -19,134 +19,134 @@  | 
                                                    ||
| 19 | 19 | */  | 
                                                        
| 20 | 20 | class TdbmController extends AbstractMoufInstanceController  | 
                                                        
| 21 | 21 |  { | 
                                                        
| 22 | - /**  | 
                                                        |
| 23 | - * @var HtmlBlock  | 
                                                        |
| 24 | - */  | 
                                                        |
| 25 | - public $content;  | 
                                                        |
| 26 | -  | 
                                                        |
| 27 | - protected $daoNamespace;  | 
                                                        |
| 28 | - protected $beanNamespace;  | 
                                                        |
| 29 | - protected $daoFactoryInstanceName;  | 
                                                        |
| 30 | - protected $autoloadDetected;  | 
                                                        |
| 31 | - ///protected $storeInUtc;  | 
                                                        |
| 32 | - protected $useCustomComposer;  | 
                                                        |
| 33 | - protected $composerFile;  | 
                                                        |
| 34 | -  | 
                                                        |
| 35 | - /**  | 
                                                        |
| 36 | - * Admin page used to display the DAO generation form.  | 
                                                        |
| 37 | - *  | 
                                                        |
| 38 | - * @Action  | 
                                                        |
| 39 | - */  | 
                                                        |
| 40 | - public function defaultAction($name, $selfedit = 'false')  | 
                                                        |
| 41 | -    { | 
                                                        |
| 42 | - $this->initController($name, $selfedit);  | 
                                                        |
| 43 | -  | 
                                                        |
| 44 | - // Fill variables  | 
                                                        |
| 45 | - $this->daoNamespace = self::getFromConfiguration($this->moufManager, $name, 'daoNamespace');  | 
                                                        |
| 46 | - $this->beanNamespace = self::getFromConfiguration($this->moufManager, $name, 'beanNamespace');  | 
                                                        |
| 47 | - $this->daoFactoryInstanceName = self::getFromConfiguration($this->moufManager, $name, 'daoFactoryInstanceName');  | 
                                                        |
| 48 | - //$this->storeInUtc = self::getFromConfiguration($this->moufManager, $name, 'storeInUtc');  | 
                                                        |
| 49 | - $pathFinder = self::getFromConfiguration($this->moufManager, $name, 'pathFinder');  | 
                                                        |
| 50 | -        if ($pathFinder !== null) { | 
                                                        |
| 51 | -            $this->composerFile = $pathFinder->getConstructorArgumentProperty('composerFile')->getValue(); | 
                                                        |
| 52 | -        } else { | 
                                                        |
| 53 | - $this->composerFile = null;  | 
                                                        |
| 54 | - }  | 
                                                        |
| 55 | - $this->useCustomComposer = $this->composerFile ? true : false;  | 
                                                        |
| 56 | -  | 
                                                        |
| 57 | -        if ($this->daoNamespace == null && $this->beanNamespace == null) { | 
                                                        |
| 58 | - $classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json');  | 
                                                        |
| 59 | -  | 
                                                        |
| 60 | - $autoloadNamespaces = $classNameMapper->getManagedNamespaces();  | 
                                                        |
| 61 | -            if ($autoloadNamespaces) { | 
                                                        |
| 62 | - $this->autoloadDetected = true;  | 
                                                        |
| 63 | - $rootNamespace = $autoloadNamespaces[0];  | 
                                                        |
| 64 | - $this->daoNamespace = $rootNamespace.'Dao';  | 
                                                        |
| 65 | - $this->beanNamespace = $rootNamespace.'Dao\\Bean';  | 
                                                        |
| 66 | -            } else { | 
                                                        |
| 67 | - $this->autoloadDetected = false;  | 
                                                        |
| 68 | - $this->daoNamespace = 'YourApplication\\Dao';  | 
                                                        |
| 69 | - $this->beanNamespace = 'YourApplication\\Dao\\Bean';  | 
                                                        |
| 70 | - }  | 
                                                        |
| 71 | -        } else { | 
                                                        |
| 72 | - $this->autoloadDetected = true;  | 
                                                        |
| 73 | - }  | 
                                                        |
| 74 | -  | 
                                                        |
| 75 | - $this->content->addFile(__DIR__.'/../../../../views/tdbmGenerate.php', $this);  | 
                                                        |
| 76 | - $this->template->toHtml();  | 
                                                        |
| 77 | - }  | 
                                                        |
| 78 | -  | 
                                                        |
| 79 | - /**  | 
                                                        |
| 80 | - * This action generates the DAOs and Beans for the TDBM service passed in parameter.  | 
                                                        |
| 81 | - *  | 
                                                        |
| 82 | - * @Action  | 
                                                        |
| 83 | - *  | 
                                                        |
| 84 | - * @param string $name  | 
                                                        |
| 85 | - * @param bool $selfedit  | 
                                                        |
| 86 | - */  | 
                                                        |
| 87 | - public function generate($name, $daonamespace, $beannamespace, $daofactoryinstancename, /*$storeInUtc = 0,*/ $selfedit = 'false', $useCustomComposer = false, $composerFile = '')  | 
                                                        |
| 88 | -    { | 
                                                        |
| 89 | - $this->initController($name, $selfedit);  | 
                                                        |
| 90 | -  | 
                                                        |
| 91 | - self::generateDaos($this->moufManager, $name, $daonamespace, $beannamespace, $daofactoryinstancename, $selfedit, /*$storeInUtc,*/ $useCustomComposer, $composerFile);  | 
                                                        |
| 92 | -  | 
                                                        |
| 93 | - // TODO: better: we should redirect to a screen that list the number of DAOs generated, etc...  | 
                                                        |
| 94 | -        header('Location: '.ROOT_URL.'ajaxinstance/?name='.urlencode($name).'&selfedit='.$selfedit); | 
                                                        |
| 95 | - }  | 
                                                        |
| 96 | -  | 
                                                        |
| 97 | - /**  | 
                                                        |
| 98 | - * This function generates the DAOs and Beans for the TDBM service passed in parameter.  | 
                                                        |
| 99 | - *  | 
                                                        |
| 100 | - * @param MoufManager $moufManager  | 
                                                        |
| 101 | - * @param string $name  | 
                                                        |
| 102 | - * @param string $daonamespace  | 
                                                        |
| 103 | - * @param string $beannamespace  | 
                                                        |
| 104 | - * @param string $selfedit  | 
                                                        |
| 105 | - *  | 
                                                        |
| 106 | - * @throws \Mouf\MoufException  | 
                                                        |
| 107 | - */  | 
                                                        |
| 108 | - public static function generateDaos(MoufManager $moufManager, $name, $daonamespace, $beannamespace, $daofactoryinstancename, $selfedit = 'false', /*$storeInUtc = null,*/ $useCustomComposer = null, $composerFile = null)  | 
                                                        |
| 109 | -    { | 
                                                        |
| 110 | - self::setInConfiguration($moufManager, $name, 'daoNamespace', $daonamespace);  | 
                                                        |
| 111 | - self::setInConfiguration($moufManager, $name, 'beanNamespace', $beannamespace);  | 
                                                        |
| 112 | - self::setInConfiguration($moufManager, $name, 'daoFactoryInstanceName', $daofactoryinstancename);  | 
                                                        |
| 113 | - //self::setInConfiguration($moufManager, $name, 'storeInUtc', $storeInUtc);  | 
                                                        |
| 114 | -        if ($useCustomComposer) { | 
                                                        |
| 115 | - $pathFinder = $moufManager->createInstance(PathFinder::class);  | 
                                                        |
| 116 | -            $pathFinder->getConstructorArgumentProperty('composerFile')->setValue($composerFile); | 
                                                        |
| 117 | - self::setInConfiguration($moufManager, $name, 'pathFinder', $pathFinder);  | 
                                                        |
| 118 | -        } else { | 
                                                        |
| 119 | - self::setInConfiguration($moufManager, $name, 'pathFinder', null);  | 
                                                        |
| 120 | - }  | 
                                                        |
| 121 | - // Let's rewrite before calling the DAO generator  | 
                                                        |
| 122 | - $moufManager->rewriteMouf();  | 
                                                        |
| 123 | -  | 
                                                        |
| 124 | -  | 
                                                        |
| 125 | - $tdbmService = new InstanceProxy($name);  | 
                                                        |
| 126 | - /* @var $tdbmService TDBMService */  | 
                                                        |
| 127 | - $tdbmService->generateAllDaosAndBeans();  | 
                                                        |
| 128 | - }  | 
                                                        |
| 129 | -  | 
                                                        |
| 130 | - private static function getConfigurationDescriptor(MoufManager $moufManager, string $tdbmInstanceName)  | 
                                                        |
| 131 | -    { | 
                                                        |
| 132 | -        return $moufManager->getInstanceDescriptor($tdbmInstanceName)->getConstructorArgumentProperty('configuration')->getValue(); | 
                                                        |
| 133 | - }  | 
                                                        |
| 134 | -  | 
                                                        |
| 135 | - private static function getFromConfiguration(MoufManager $moufManager, string $tdbmInstanceName, string $property)  | 
                                                        |
| 136 | -    { | 
                                                        |
| 137 | - $configuration = self::getConfigurationDescriptor($moufManager, $tdbmInstanceName);  | 
                                                        |
| 138 | -        if ($configuration === null) { | 
                                                        |
| 139 | -            throw new \RuntimeException('Unable to find the configuration object linked to TDBMService.'); | 
                                                        |
| 140 | - }  | 
                                                        |
| 141 | - return $configuration->getProperty($property)->getValue();  | 
                                                        |
| 142 | - }  | 
                                                        |
| 143 | -  | 
                                                        |
| 144 | - private static function setInConfiguration(MoufManager $moufManager, string $tdbmInstanceName, string $property, ?string $value)  | 
                                                        |
| 145 | -    { | 
                                                        |
| 146 | - $configuration = self::getConfigurationDescriptor($moufManager, $tdbmInstanceName);  | 
                                                        |
| 147 | -        if ($configuration === null) { | 
                                                        |
| 148 | -            throw new \RuntimeException('Unable to find the configuration object linked to TDBMService.'); | 
                                                        |
| 149 | - }  | 
                                                        |
| 150 | - $configuration->getProperty($property)->setValue($value);  | 
                                                        |
| 151 | - }  | 
                                                        |
| 22 | + /**  | 
                                                        |
| 23 | + * @var HtmlBlock  | 
                                                        |
| 24 | + */  | 
                                                        |
| 25 | + public $content;  | 
                                                        |
| 26 | +  | 
                                                        |
| 27 | + protected $daoNamespace;  | 
                                                        |
| 28 | + protected $beanNamespace;  | 
                                                        |
| 29 | + protected $daoFactoryInstanceName;  | 
                                                        |
| 30 | + protected $autoloadDetected;  | 
                                                        |
| 31 | + ///protected $storeInUtc;  | 
                                                        |
| 32 | + protected $useCustomComposer;  | 
                                                        |
| 33 | + protected $composerFile;  | 
                                                        |
| 34 | +  | 
                                                        |
| 35 | + /**  | 
                                                        |
| 36 | + * Admin page used to display the DAO generation form.  | 
                                                        |
| 37 | + *  | 
                                                        |
| 38 | + * @Action  | 
                                                        |
| 39 | + */  | 
                                                        |
| 40 | + public function defaultAction($name, $selfedit = 'false')  | 
                                                        |
| 41 | +	{ | 
                                                        |
| 42 | + $this->initController($name, $selfedit);  | 
                                                        |
| 43 | +  | 
                                                        |
| 44 | + // Fill variables  | 
                                                        |
| 45 | + $this->daoNamespace = self::getFromConfiguration($this->moufManager, $name, 'daoNamespace');  | 
                                                        |
| 46 | + $this->beanNamespace = self::getFromConfiguration($this->moufManager, $name, 'beanNamespace');  | 
                                                        |
| 47 | + $this->daoFactoryInstanceName = self::getFromConfiguration($this->moufManager, $name, 'daoFactoryInstanceName');  | 
                                                        |
| 48 | + //$this->storeInUtc = self::getFromConfiguration($this->moufManager, $name, 'storeInUtc');  | 
                                                        |
| 49 | + $pathFinder = self::getFromConfiguration($this->moufManager, $name, 'pathFinder');  | 
                                                        |
| 50 | +		if ($pathFinder !== null) { | 
                                                        |
| 51 | +			$this->composerFile = $pathFinder->getConstructorArgumentProperty('composerFile')->getValue(); | 
                                                        |
| 52 | +		} else { | 
                                                        |
| 53 | + $this->composerFile = null;  | 
                                                        |
| 54 | + }  | 
                                                        |
| 55 | + $this->useCustomComposer = $this->composerFile ? true : false;  | 
                                                        |
| 56 | +  | 
                                                        |
| 57 | +		if ($this->daoNamespace == null && $this->beanNamespace == null) { | 
                                                        |
| 58 | + $classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json');  | 
                                                        |
| 59 | +  | 
                                                        |
| 60 | + $autoloadNamespaces = $classNameMapper->getManagedNamespaces();  | 
                                                        |
| 61 | +			if ($autoloadNamespaces) { | 
                                                        |
| 62 | + $this->autoloadDetected = true;  | 
                                                        |
| 63 | + $rootNamespace = $autoloadNamespaces[0];  | 
                                                        |
| 64 | + $this->daoNamespace = $rootNamespace.'Dao';  | 
                                                        |
| 65 | + $this->beanNamespace = $rootNamespace.'Dao\\Bean';  | 
                                                        |
| 66 | +			} else { | 
                                                        |
| 67 | + $this->autoloadDetected = false;  | 
                                                        |
| 68 | + $this->daoNamespace = 'YourApplication\\Dao';  | 
                                                        |
| 69 | + $this->beanNamespace = 'YourApplication\\Dao\\Bean';  | 
                                                        |
| 70 | + }  | 
                                                        |
| 71 | +		} else { | 
                                                        |
| 72 | + $this->autoloadDetected = true;  | 
                                                        |
| 73 | + }  | 
                                                        |
| 74 | +  | 
                                                        |
| 75 | + $this->content->addFile(__DIR__.'/../../../../views/tdbmGenerate.php', $this);  | 
                                                        |
| 76 | + $this->template->toHtml();  | 
                                                        |
| 77 | + }  | 
                                                        |
| 78 | +  | 
                                                        |
| 79 | + /**  | 
                                                        |
| 80 | + * This action generates the DAOs and Beans for the TDBM service passed in parameter.  | 
                                                        |
| 81 | + *  | 
                                                        |
| 82 | + * @Action  | 
                                                        |
| 83 | + *  | 
                                                        |
| 84 | + * @param string $name  | 
                                                        |
| 85 | + * @param bool $selfedit  | 
                                                        |
| 86 | + */  | 
                                                        |
| 87 | + public function generate($name, $daonamespace, $beannamespace, $daofactoryinstancename, /*$storeInUtc = 0,*/ $selfedit = 'false', $useCustomComposer = false, $composerFile = '')  | 
                                                        |
| 88 | +	{ | 
                                                        |
| 89 | + $this->initController($name, $selfedit);  | 
                                                        |
| 90 | +  | 
                                                        |
| 91 | + self::generateDaos($this->moufManager, $name, $daonamespace, $beannamespace, $daofactoryinstancename, $selfedit, /*$storeInUtc,*/ $useCustomComposer, $composerFile);  | 
                                                        |
| 92 | +  | 
                                                        |
| 93 | + // TODO: better: we should redirect to a screen that list the number of DAOs generated, etc...  | 
                                                        |
| 94 | +		header('Location: '.ROOT_URL.'ajaxinstance/?name='.urlencode($name).'&selfedit='.$selfedit); | 
                                                        |
| 95 | + }  | 
                                                        |
| 96 | +  | 
                                                        |
| 97 | + /**  | 
                                                        |
| 98 | + * This function generates the DAOs and Beans for the TDBM service passed in parameter.  | 
                                                        |
| 99 | + *  | 
                                                        |
| 100 | + * @param MoufManager $moufManager  | 
                                                        |
| 101 | + * @param string $name  | 
                                                        |
| 102 | + * @param string $daonamespace  | 
                                                        |
| 103 | + * @param string $beannamespace  | 
                                                        |
| 104 | + * @param string $selfedit  | 
                                                        |
| 105 | + *  | 
                                                        |
| 106 | + * @throws \Mouf\MoufException  | 
                                                        |
| 107 | + */  | 
                                                        |
| 108 | + public static function generateDaos(MoufManager $moufManager, $name, $daonamespace, $beannamespace, $daofactoryinstancename, $selfedit = 'false', /*$storeInUtc = null,*/ $useCustomComposer = null, $composerFile = null)  | 
                                                        |
| 109 | +	{ | 
                                                        |
| 110 | + self::setInConfiguration($moufManager, $name, 'daoNamespace', $daonamespace);  | 
                                                        |
| 111 | + self::setInConfiguration($moufManager, $name, 'beanNamespace', $beannamespace);  | 
                                                        |
| 112 | + self::setInConfiguration($moufManager, $name, 'daoFactoryInstanceName', $daofactoryinstancename);  | 
                                                        |
| 113 | + //self::setInConfiguration($moufManager, $name, 'storeInUtc', $storeInUtc);  | 
                                                        |
| 114 | +		if ($useCustomComposer) { | 
                                                        |
| 115 | + $pathFinder = $moufManager->createInstance(PathFinder::class);  | 
                                                        |
| 116 | +			$pathFinder->getConstructorArgumentProperty('composerFile')->setValue($composerFile); | 
                                                        |
| 117 | + self::setInConfiguration($moufManager, $name, 'pathFinder', $pathFinder);  | 
                                                        |
| 118 | +		} else { | 
                                                        |
| 119 | + self::setInConfiguration($moufManager, $name, 'pathFinder', null);  | 
                                                        |
| 120 | + }  | 
                                                        |
| 121 | + // Let's rewrite before calling the DAO generator  | 
                                                        |
| 122 | + $moufManager->rewriteMouf();  | 
                                                        |
| 123 | +  | 
                                                        |
| 124 | +  | 
                                                        |
| 125 | + $tdbmService = new InstanceProxy($name);  | 
                                                        |
| 126 | + /* @var $tdbmService TDBMService */  | 
                                                        |
| 127 | + $tdbmService->generateAllDaosAndBeans();  | 
                                                        |
| 128 | + }  | 
                                                        |
| 129 | +  | 
                                                        |
| 130 | + private static function getConfigurationDescriptor(MoufManager $moufManager, string $tdbmInstanceName)  | 
                                                        |
| 131 | +	{ | 
                                                        |
| 132 | +		return $moufManager->getInstanceDescriptor($tdbmInstanceName)->getConstructorArgumentProperty('configuration')->getValue(); | 
                                                        |
| 133 | + }  | 
                                                        |
| 134 | +  | 
                                                        |
| 135 | + private static function getFromConfiguration(MoufManager $moufManager, string $tdbmInstanceName, string $property)  | 
                                                        |
| 136 | +	{ | 
                                                        |
| 137 | + $configuration = self::getConfigurationDescriptor($moufManager, $tdbmInstanceName);  | 
                                                        |
| 138 | +		if ($configuration === null) { | 
                                                        |
| 139 | +			throw new \RuntimeException('Unable to find the configuration object linked to TDBMService.'); | 
                                                        |
| 140 | + }  | 
                                                        |
| 141 | + return $configuration->getProperty($property)->getValue();  | 
                                                        |
| 142 | + }  | 
                                                        |
| 143 | +  | 
                                                        |
| 144 | + private static function setInConfiguration(MoufManager $moufManager, string $tdbmInstanceName, string $property, ?string $value)  | 
                                                        |
| 145 | +	{ | 
                                                        |
| 146 | + $configuration = self::getConfigurationDescriptor($moufManager, $tdbmInstanceName);  | 
                                                        |
| 147 | +		if ($configuration === null) { | 
                                                        |
| 148 | +			throw new \RuntimeException('Unable to find the configuration object linked to TDBMService.'); | 
                                                        |
| 149 | + }  | 
                                                        |
| 150 | + $configuration->getProperty($property)->setValue($value);  | 
                                                        |
| 151 | + }  | 
                                                        |
| 152 | 152 | }  | 
                                                        
@@ -6,7 +6,6 @@  | 
                                                    ||
| 6 | 6 | use Mouf\Controllers\AbstractMoufInstanceController;  | 
                                                        
| 7 | 7 | use TheCodingMachine\TDBM\TDBMService;  | 
                                                        
| 8 | 8 | use TheCodingMachine\TDBM\Utils\PathFinder\PathFinder;  | 
                                                        
| 9 | -use TheCodingMachine\TDBM\Utils\TDBMDaoGenerator;  | 
                                                        |
| 10 | 9 | use Mouf\Html\HtmlElement\HtmlBlock;  | 
                                                        
| 11 | 10 | use Mouf\MoufManager;  | 
                                                        
| 12 | 11 | use Mouf\InstanceProxy;  | 
                                                        
@@ -14,73 +14,73 @@  | 
                                                    ||
| 14 | 14 | class MoufDiListener implements GeneratorListenerInterface  | 
                                                        
| 15 | 15 |  { | 
                                                        
| 16 | 16 | |
| 17 | - /**  | 
                                                        |
| 18 | - * @param ConfigurationInterface $configuration  | 
                                                        |
| 19 | - * @param BeanDescriptorInterface[] $beanDescriptors  | 
                                                        |
| 20 | - */  | 
                                                        |
| 21 | - public function onGenerate(ConfigurationInterface $configuration, array $beanDescriptors): void  | 
                                                        |
| 22 | -    { | 
                                                        |
| 23 | - // Let's generate the needed instance in Mouf.  | 
                                                        |
| 24 | - $moufManager = MoufManager::getMoufManager();  | 
                                                        |
| 25 | -  | 
                                                        |
| 26 | - $daoFactoryInstanceName = null;  | 
                                                        |
| 27 | -        if ($configuration instanceof MoufConfiguration) { | 
                                                        |
| 28 | - $daoFactoryInstanceName = $configuration->getDaoFactoryInstanceName();  | 
                                                        |
| 29 | - $daoFactoryClassName = $configuration->getDaoNamespace().'\\Generated\\'.$configuration->getNamingStrategy()->getDaoFactoryClassName();  | 
                                                        |
| 30 | - $moufManager->declareComponent($daoFactoryInstanceName, $daoFactoryClassName, false, MoufManager::DECLARE_ON_EXIST_KEEP_INCOMING_LINKS);  | 
                                                        |
| 31 | - }  | 
                                                        |
| 32 | -  | 
                                                        |
| 33 | - $tdbmServiceInstanceName = $this->getTdbmInstanceName($configuration);  | 
                                                        |
| 34 | -  | 
                                                        |
| 35 | -        foreach ($beanDescriptors as $beanDescriptor) { | 
                                                        |
| 36 | - $daoName = $beanDescriptor->getDaoClassName();  | 
                                                        |
| 37 | -  | 
                                                        |
| 38 | - // Rename all DAOs to full-class name (migration from 5.0 to 5.1+ naming schema)  | 
                                                        |
| 39 | - $instanceName = TDBMDaoGenerator::toVariableName($daoName);  | 
                                                        |
| 40 | -            if ($moufManager->instanceExists($instanceName) && !$moufManager->instanceExists($configuration->getDaoNamespace().'\\'.$daoName)) { | 
                                                        |
| 41 | - $moufManager->renameComponent($instanceName, $configuration->getDaoNamespace().'\\'.$daoName);  | 
                                                        |
| 42 | -  | 
                                                        |
| 43 | - // Let's create a "Link" between old Mouf::getXXXDao and new Mouf::getNamespaceXXXDao  | 
                                                        |
| 44 | -                $moufManager->createInstanceByCode()->setName($instanceName)->setCode('return $container->get('.var_export($configuration->getDaoNamespace().'\\'.$daoName, true).');'); | 
                                                        |
| 45 | -  | 
                                                        |
| 46 | - // Let's unset the setter. It is useless now.  | 
                                                        |
| 47 | -                if ($daoFactoryInstanceName !== null) { | 
                                                        |
| 48 | - $moufManager->unsetParameterForSetter($daoFactoryInstanceName, 'set'.$daoName);  | 
                                                        |
| 49 | - }  | 
                                                        |
| 50 | - }  | 
                                                        |
| 51 | -  | 
                                                        |
| 52 | - $instanceName = $configuration->getDaoNamespace().'\\'.$daoName;  | 
                                                        |
| 53 | -            if (!$moufManager->instanceExists($instanceName)) { | 
                                                        |
| 54 | - $moufManager->declareComponent($instanceName, $configuration->getDaoNamespace().'\\'.$daoName);  | 
                                                        |
| 55 | - }  | 
                                                        |
| 56 | - $moufManager->setParameterViaConstructor($instanceName, 0, $tdbmServiceInstanceName, 'object');  | 
                                                        |
| 57 | - }  | 
                                                        |
| 58 | -  | 
                                                        |
| 59 | -        if ($daoFactoryInstanceName !== null) { | 
                                                        |
| 60 | - $moufManager->setParameterViaConstructor($daoFactoryInstanceName, 0, 'return $container;', 'primitive', 'php');  | 
                                                        |
| 61 | - }  | 
                                                        |
| 62 | -  | 
                                                        |
| 63 | - $moufManager->rewriteMouf();  | 
                                                        |
| 64 | - }  | 
                                                        |
| 65 | -  | 
                                                        |
| 66 | - private function getTdbmInstanceName(ConfigurationInterface $configuration) : string  | 
                                                        |
| 67 | -    { | 
                                                        |
| 68 | - $moufManager = MoufManager::getMoufManager();  | 
                                                        |
| 69 | -  | 
                                                        |
| 70 | - $configurationInstanceName = $moufManager->findInstanceName($configuration);  | 
                                                        |
| 71 | -        if (!$configurationInstanceName) { | 
                                                        |
| 72 | -            throw new \TDBMException('Could not find TDBM instance for configuration object.'); | 
                                                        |
| 73 | - }  | 
                                                        |
| 74 | -  | 
                                                        |
| 75 | - // Let's find the configuration  | 
                                                        |
| 76 | - $tdbmServicesNames = $moufManager->findInstances(TDBMService::class);  | 
                                                        |
| 77 | -  | 
                                                        |
| 78 | -        foreach ($tdbmServicesNames as $name) { | 
                                                        |
| 79 | -            if ($moufManager->getInstanceDescriptor($name)->getConstructorArgumentProperty('configuration')->getValue()->getName() === $configurationInstanceName) { | 
                                                        |
| 80 | - return $name;  | 
                                                        |
| 81 | - }  | 
                                                        |
| 82 | - }  | 
                                                        |
| 83 | -  | 
                                                        |
| 84 | -        throw new \TDBMException('Could not find TDBMService instance.'); | 
                                                        |
| 85 | - }  | 
                                                        |
| 17 | + /**  | 
                                                        |
| 18 | + * @param ConfigurationInterface $configuration  | 
                                                        |
| 19 | + * @param BeanDescriptorInterface[] $beanDescriptors  | 
                                                        |
| 20 | + */  | 
                                                        |
| 21 | + public function onGenerate(ConfigurationInterface $configuration, array $beanDescriptors): void  | 
                                                        |
| 22 | +	{ | 
                                                        |
| 23 | + // Let's generate the needed instance in Mouf.  | 
                                                        |
| 24 | + $moufManager = MoufManager::getMoufManager();  | 
                                                        |
| 25 | +  | 
                                                        |
| 26 | + $daoFactoryInstanceName = null;  | 
                                                        |
| 27 | +		if ($configuration instanceof MoufConfiguration) { | 
                                                        |
| 28 | + $daoFactoryInstanceName = $configuration->getDaoFactoryInstanceName();  | 
                                                        |
| 29 | + $daoFactoryClassName = $configuration->getDaoNamespace().'\\Generated\\'.$configuration->getNamingStrategy()->getDaoFactoryClassName();  | 
                                                        |
| 30 | + $moufManager->declareComponent($daoFactoryInstanceName, $daoFactoryClassName, false, MoufManager::DECLARE_ON_EXIST_KEEP_INCOMING_LINKS);  | 
                                                        |
| 31 | + }  | 
                                                        |
| 32 | +  | 
                                                        |
| 33 | + $tdbmServiceInstanceName = $this->getTdbmInstanceName($configuration);  | 
                                                        |
| 34 | +  | 
                                                        |
| 35 | +		foreach ($beanDescriptors as $beanDescriptor) { | 
                                                        |
| 36 | + $daoName = $beanDescriptor->getDaoClassName();  | 
                                                        |
| 37 | +  | 
                                                        |
| 38 | + // Rename all DAOs to full-class name (migration from 5.0 to 5.1+ naming schema)  | 
                                                        |
| 39 | + $instanceName = TDBMDaoGenerator::toVariableName($daoName);  | 
                                                        |
| 40 | +			if ($moufManager->instanceExists($instanceName) && !$moufManager->instanceExists($configuration->getDaoNamespace().'\\'.$daoName)) { | 
                                                        |
| 41 | + $moufManager->renameComponent($instanceName, $configuration->getDaoNamespace().'\\'.$daoName);  | 
                                                        |
| 42 | +  | 
                                                        |
| 43 | + // Let's create a "Link" between old Mouf::getXXXDao and new Mouf::getNamespaceXXXDao  | 
                                                        |
| 44 | +				$moufManager->createInstanceByCode()->setName($instanceName)->setCode('return $container->get('.var_export($configuration->getDaoNamespace().'\\'.$daoName, true).');'); | 
                                                        |
| 45 | +  | 
                                                        |
| 46 | + // Let's unset the setter. It is useless now.  | 
                                                        |
| 47 | +				if ($daoFactoryInstanceName !== null) { | 
                                                        |
| 48 | + $moufManager->unsetParameterForSetter($daoFactoryInstanceName, 'set'.$daoName);  | 
                                                        |
| 49 | + }  | 
                                                        |
| 50 | + }  | 
                                                        |
| 51 | +  | 
                                                        |
| 52 | + $instanceName = $configuration->getDaoNamespace().'\\'.$daoName;  | 
                                                        |
| 53 | +			if (!$moufManager->instanceExists($instanceName)) { | 
                                                        |
| 54 | + $moufManager->declareComponent($instanceName, $configuration->getDaoNamespace().'\\'.$daoName);  | 
                                                        |
| 55 | + }  | 
                                                        |
| 56 | + $moufManager->setParameterViaConstructor($instanceName, 0, $tdbmServiceInstanceName, 'object');  | 
                                                        |
| 57 | + }  | 
                                                        |
| 58 | +  | 
                                                        |
| 59 | +		if ($daoFactoryInstanceName !== null) { | 
                                                        |
| 60 | + $moufManager->setParameterViaConstructor($daoFactoryInstanceName, 0, 'return $container;', 'primitive', 'php');  | 
                                                        |
| 61 | + }  | 
                                                        |
| 62 | +  | 
                                                        |
| 63 | + $moufManager->rewriteMouf();  | 
                                                        |
| 64 | + }  | 
                                                        |
| 65 | +  | 
                                                        |
| 66 | + private function getTdbmInstanceName(ConfigurationInterface $configuration) : string  | 
                                                        |
| 67 | +	{ | 
                                                        |
| 68 | + $moufManager = MoufManager::getMoufManager();  | 
                                                        |
| 69 | +  | 
                                                        |
| 70 | + $configurationInstanceName = $moufManager->findInstanceName($configuration);  | 
                                                        |
| 71 | +		if (!$configurationInstanceName) { | 
                                                        |
| 72 | +			throw new \TDBMException('Could not find TDBM instance for configuration object.'); | 
                                                        |
| 73 | + }  | 
                                                        |
| 74 | +  | 
                                                        |
| 75 | + // Let's find the configuration  | 
                                                        |
| 76 | + $tdbmServicesNames = $moufManager->findInstances(TDBMService::class);  | 
                                                        |
| 77 | +  | 
                                                        |
| 78 | +		foreach ($tdbmServicesNames as $name) { | 
                                                        |
| 79 | +			if ($moufManager->getInstanceDescriptor($name)->getConstructorArgumentProperty('configuration')->getValue()->getName() === $configurationInstanceName) { | 
                                                        |
| 80 | + return $name;  | 
                                                        |
| 81 | + }  | 
                                                        |
| 82 | + }  | 
                                                        |
| 83 | +  | 
                                                        |
| 84 | +		throw new \TDBMException('Could not find TDBMService instance.'); | 
                                                        |
| 85 | + }  | 
                                                        |
| 86 | 86 | }  |