@@ -15,168 +15,168 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class TdbmInstallController extends Controller |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @var HtmlBlock |
|
| 20 | - */ |
|
| 21 | - public $content; |
|
| 22 | - |
|
| 23 | - public $selfedit; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * The active MoufManager to be edited/viewed. |
|
| 27 | - * |
|
| 28 | - * @var MoufManager |
|
| 29 | - */ |
|
| 30 | - public $moufManager; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * The template used by the main page for mouf. |
|
| 34 | - * |
|
| 35 | - * @Property |
|
| 36 | - * @Compulsory |
|
| 37 | - * |
|
| 38 | - * @var TemplateInterface |
|
| 39 | - */ |
|
| 40 | - public $template; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Displays the first install screen. |
|
| 44 | - * |
|
| 45 | - * @Action |
|
| 46 | - * @Logged |
|
| 47 | - * |
|
| 48 | - * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only) |
|
| 49 | - */ |
|
| 50 | - public function defaultAction($selfedit = 'false') |
|
| 51 | - { |
|
| 52 | - $this->selfedit = $selfedit; |
|
| 53 | - |
|
| 54 | - if ($selfedit == 'true') { |
|
| 55 | - $this->moufManager = MoufManager::getMoufManager(); |
|
| 56 | - } else { |
|
| 57 | - $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - $this->content->addFile(dirname(__FILE__).'/../../../../views/installStep1.php', $this); |
|
| 61 | - $this->template->toHtml(); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Skips the install process. |
|
| 66 | - * |
|
| 67 | - * @Action |
|
| 68 | - * @Logged |
|
| 69 | - * |
|
| 70 | - * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only) |
|
| 71 | - */ |
|
| 72 | - public function skip($selfedit = 'false') |
|
| 73 | - { |
|
| 74 | - InstallUtils::continueInstall($selfedit == 'true'); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - protected $daoNamespace; |
|
| 78 | - protected $beanNamespace; |
|
| 79 | - protected $autoloadDetected; |
|
| 80 | - protected $storeInUtc; |
|
| 81 | - protected $useCustomComposer = false; |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * Displays the second install screen. |
|
| 85 | - * |
|
| 86 | - * @Action |
|
| 87 | - * @Logged |
|
| 88 | - * |
|
| 89 | - * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only) |
|
| 90 | - */ |
|
| 91 | - public function configure($selfedit = 'false') |
|
| 92 | - { |
|
| 93 | - $this->selfedit = $selfedit; |
|
| 94 | - |
|
| 95 | - if ($selfedit == 'true') { |
|
| 96 | - $this->moufManager = MoufManager::getMoufManager(); |
|
| 97 | - } else { |
|
| 98 | - $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - // Let's start by performing basic checks about the instances we assume to exist. |
|
| 102 | - if (!$this->moufManager->instanceExists('dbalConnection')) { |
|
| 103 | - $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."); |
|
| 104 | - |
|
| 105 | - return; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - $this->daoNamespace = $this->moufManager->getVariable('tdbmDefaultDaoNamespace_tdbmService'); |
|
| 109 | - $this->beanNamespace = $this->moufManager->getVariable('tdbmDefaultBeanNamespace_tdbmService'); |
|
| 110 | - |
|
| 111 | - if ($this->daoNamespace == null && $this->beanNamespace == null) { |
|
| 112 | - $classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json'); |
|
| 113 | - |
|
| 114 | - $autoloadNamespaces = $classNameMapper->getManagedNamespaces(); |
|
| 115 | - if ($autoloadNamespaces) { |
|
| 116 | - $this->autoloadDetected = true; |
|
| 117 | - $rootNamespace = $autoloadNamespaces[0]; |
|
| 118 | - $this->daoNamespace = $rootNamespace.'Model\\Dao'; |
|
| 119 | - $this->beanNamespace = $rootNamespace.'Model\\Bean'; |
|
| 120 | - } else { |
|
| 121 | - $this->autoloadDetected = false; |
|
| 122 | - $this->daoNamespace = 'YourApplication\\Model\\Dao'; |
|
| 123 | - $this->beanNamespace = 'YourApplication\\Model\\Bean'; |
|
| 124 | - } |
|
| 125 | - } else { |
|
| 126 | - $this->autoloadDetected = true; |
|
| 127 | - } |
|
| 128 | - $this->defaultPath = true; |
|
| 129 | - $this->storePath = ''; |
|
| 130 | - |
|
| 131 | - $this->castDatesToDateTime = true; |
|
| 132 | - |
|
| 133 | - $this->content->addFile(dirname(__FILE__).'/../../../../views/installStep2.php', $this); |
|
| 134 | - $this->template->toHtml(); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * This action generates the TDBM instance, then the DAOs and Beans. |
|
| 139 | - * |
|
| 140 | - * @Action |
|
| 141 | - * |
|
| 142 | - * @param string $daonamespace |
|
| 143 | - * @param string $beannamespace |
|
| 144 | - * @param int $storeInUtc |
|
| 145 | - * @param string $selfedit |
|
| 146 | - * |
|
| 147 | - * @throws \Mouf\MoufException |
|
| 148 | - */ |
|
| 149 | - public function generate($daonamespace, $beannamespace, $storeInUtc = 0, $selfedit = 'false', $defaultPath = false, $storePath = '') |
|
| 150 | - { |
|
| 151 | - $this->selfedit = $selfedit; |
|
| 152 | - |
|
| 153 | - if ($selfedit == 'true') { |
|
| 154 | - $this->moufManager = MoufManager::getMoufManager(); |
|
| 155 | - } else { |
|
| 156 | - $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - $doctrineCache = $this->moufManager->getInstanceDescriptor('defaultDoctrineCache'); |
|
| 160 | - |
|
| 161 | - if (!$this->moufManager->instanceExists('tdbmService')) { |
|
| 162 | - $tdbmService = $this->moufManager->createInstance('Mouf\\Database\\TDBM\\TDBMService')->setName('tdbmService'); |
|
| 163 | - $tdbmService->getConstructorArgumentProperty('connection')->setValue($this->moufManager->getInstanceDescriptor('dbalConnection')); |
|
| 164 | - $tdbmService->getConstructorArgumentProperty('cache')->setValue($doctrineCache); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - $this->moufManager->rewriteMouf(); |
|
| 168 | - |
|
| 169 | - TdbmController::generateDaos($this->moufManager, 'tdbmService', $daonamespace, $beannamespace, 'DaoFactory', 'daoFactory', $selfedit, $storeInUtc, $defaultPath, $storePath); |
|
| 170 | - |
|
| 171 | - InstallUtils::continueInstall($selfedit == 'true'); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - protected $errorMsg; |
|
| 175 | - |
|
| 176 | - private function displayErrorMsg($msg) |
|
| 177 | - { |
|
| 178 | - $this->errorMsg = $msg; |
|
| 179 | - $this->content->addFile(dirname(__FILE__).'/../../../../views/installError.php', $this); |
|
| 180 | - $this->template->toHtml(); |
|
| 181 | - } |
|
| 18 | + /** |
|
| 19 | + * @var HtmlBlock |
|
| 20 | + */ |
|
| 21 | + public $content; |
|
| 22 | + |
|
| 23 | + public $selfedit; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * The active MoufManager to be edited/viewed. |
|
| 27 | + * |
|
| 28 | + * @var MoufManager |
|
| 29 | + */ |
|
| 30 | + public $moufManager; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * The template used by the main page for mouf. |
|
| 34 | + * |
|
| 35 | + * @Property |
|
| 36 | + * @Compulsory |
|
| 37 | + * |
|
| 38 | + * @var TemplateInterface |
|
| 39 | + */ |
|
| 40 | + public $template; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Displays the first install screen. |
|
| 44 | + * |
|
| 45 | + * @Action |
|
| 46 | + * @Logged |
|
| 47 | + * |
|
| 48 | + * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only) |
|
| 49 | + */ |
|
| 50 | + public function defaultAction($selfedit = 'false') |
|
| 51 | + { |
|
| 52 | + $this->selfedit = $selfedit; |
|
| 53 | + |
|
| 54 | + if ($selfedit == 'true') { |
|
| 55 | + $this->moufManager = MoufManager::getMoufManager(); |
|
| 56 | + } else { |
|
| 57 | + $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + $this->content->addFile(dirname(__FILE__).'/../../../../views/installStep1.php', $this); |
|
| 61 | + $this->template->toHtml(); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Skips the install process. |
|
| 66 | + * |
|
| 67 | + * @Action |
|
| 68 | + * @Logged |
|
| 69 | + * |
|
| 70 | + * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only) |
|
| 71 | + */ |
|
| 72 | + public function skip($selfedit = 'false') |
|
| 73 | + { |
|
| 74 | + InstallUtils::continueInstall($selfedit == 'true'); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + protected $daoNamespace; |
|
| 78 | + protected $beanNamespace; |
|
| 79 | + protected $autoloadDetected; |
|
| 80 | + protected $storeInUtc; |
|
| 81 | + protected $useCustomComposer = false; |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * Displays the second install screen. |
|
| 85 | + * |
|
| 86 | + * @Action |
|
| 87 | + * @Logged |
|
| 88 | + * |
|
| 89 | + * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only) |
|
| 90 | + */ |
|
| 91 | + public function configure($selfedit = 'false') |
|
| 92 | + { |
|
| 93 | + $this->selfedit = $selfedit; |
|
| 94 | + |
|
| 95 | + if ($selfedit == 'true') { |
|
| 96 | + $this->moufManager = MoufManager::getMoufManager(); |
|
| 97 | + } else { |
|
| 98 | + $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + // Let's start by performing basic checks about the instances we assume to exist. |
|
| 102 | + if (!$this->moufManager->instanceExists('dbalConnection')) { |
|
| 103 | + $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."); |
|
| 104 | + |
|
| 105 | + return; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + $this->daoNamespace = $this->moufManager->getVariable('tdbmDefaultDaoNamespace_tdbmService'); |
|
| 109 | + $this->beanNamespace = $this->moufManager->getVariable('tdbmDefaultBeanNamespace_tdbmService'); |
|
| 110 | + |
|
| 111 | + if ($this->daoNamespace == null && $this->beanNamespace == null) { |
|
| 112 | + $classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json'); |
|
| 113 | + |
|
| 114 | + $autoloadNamespaces = $classNameMapper->getManagedNamespaces(); |
|
| 115 | + if ($autoloadNamespaces) { |
|
| 116 | + $this->autoloadDetected = true; |
|
| 117 | + $rootNamespace = $autoloadNamespaces[0]; |
|
| 118 | + $this->daoNamespace = $rootNamespace.'Model\\Dao'; |
|
| 119 | + $this->beanNamespace = $rootNamespace.'Model\\Bean'; |
|
| 120 | + } else { |
|
| 121 | + $this->autoloadDetected = false; |
|
| 122 | + $this->daoNamespace = 'YourApplication\\Model\\Dao'; |
|
| 123 | + $this->beanNamespace = 'YourApplication\\Model\\Bean'; |
|
| 124 | + } |
|
| 125 | + } else { |
|
| 126 | + $this->autoloadDetected = true; |
|
| 127 | + } |
|
| 128 | + $this->defaultPath = true; |
|
| 129 | + $this->storePath = ''; |
|
| 130 | + |
|
| 131 | + $this->castDatesToDateTime = true; |
|
| 132 | + |
|
| 133 | + $this->content->addFile(dirname(__FILE__).'/../../../../views/installStep2.php', $this); |
|
| 134 | + $this->template->toHtml(); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * This action generates the TDBM instance, then the DAOs and Beans. |
|
| 139 | + * |
|
| 140 | + * @Action |
|
| 141 | + * |
|
| 142 | + * @param string $daonamespace |
|
| 143 | + * @param string $beannamespace |
|
| 144 | + * @param int $storeInUtc |
|
| 145 | + * @param string $selfedit |
|
| 146 | + * |
|
| 147 | + * @throws \Mouf\MoufException |
|
| 148 | + */ |
|
| 149 | + public function generate($daonamespace, $beannamespace, $storeInUtc = 0, $selfedit = 'false', $defaultPath = false, $storePath = '') |
|
| 150 | + { |
|
| 151 | + $this->selfedit = $selfedit; |
|
| 152 | + |
|
| 153 | + if ($selfedit == 'true') { |
|
| 154 | + $this->moufManager = MoufManager::getMoufManager(); |
|
| 155 | + } else { |
|
| 156 | + $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + $doctrineCache = $this->moufManager->getInstanceDescriptor('defaultDoctrineCache'); |
|
| 160 | + |
|
| 161 | + if (!$this->moufManager->instanceExists('tdbmService')) { |
|
| 162 | + $tdbmService = $this->moufManager->createInstance('Mouf\\Database\\TDBM\\TDBMService')->setName('tdbmService'); |
|
| 163 | + $tdbmService->getConstructorArgumentProperty('connection')->setValue($this->moufManager->getInstanceDescriptor('dbalConnection')); |
|
| 164 | + $tdbmService->getConstructorArgumentProperty('cache')->setValue($doctrineCache); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + $this->moufManager->rewriteMouf(); |
|
| 168 | + |
|
| 169 | + TdbmController::generateDaos($this->moufManager, 'tdbmService', $daonamespace, $beannamespace, 'DaoFactory', 'daoFactory', $selfedit, $storeInUtc, $defaultPath, $storePath); |
|
| 170 | + |
|
| 171 | + InstallUtils::continueInstall($selfedit == 'true'); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + protected $errorMsg; |
|
| 175 | + |
|
| 176 | + private function displayErrorMsg($msg) |
|
| 177 | + { |
|
| 178 | + $this->errorMsg = $msg; |
|
| 179 | + $this->content->addFile(dirname(__FILE__).'/../../../../views/installError.php', $this); |
|
| 180 | + $this->template->toHtml(); |
|
| 181 | + } |
|
| 182 | 182 | } |