1 | <?php |
||
22 | class TdbmInstallController extends Controller |
||
23 | { |
||
24 | /** |
||
25 | * @var HtmlBlock |
||
26 | */ |
||
27 | public $content; |
||
28 | |||
29 | public $selfedit; |
||
30 | |||
31 | /** |
||
32 | * The active MoufManager to be edited/viewed. |
||
33 | * |
||
34 | * @var MoufManager |
||
35 | */ |
||
36 | public $moufManager; |
||
37 | |||
38 | /** |
||
39 | * The template used by the main page for mouf. |
||
40 | * |
||
41 | * @Property |
||
42 | * @Compulsory |
||
43 | * |
||
44 | * @var TemplateInterface |
||
45 | */ |
||
46 | public $template; |
||
47 | |||
48 | /** |
||
49 | * Displays the first install screen. |
||
50 | * |
||
51 | * @Action |
||
52 | * @Logged |
||
53 | * |
||
54 | * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only) |
||
55 | */ |
||
56 | public function defaultAction($selfedit = 'false') |
||
69 | |||
70 | /** |
||
71 | * Skips the install process. |
||
72 | * |
||
73 | * @Action |
||
74 | * @Logged |
||
75 | * |
||
76 | * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only) |
||
77 | */ |
||
78 | public function skip($selfedit = 'false') |
||
82 | |||
83 | protected $daoNamespace; |
||
84 | protected $beanNamespace; |
||
85 | protected $autoloadDetected; |
||
86 | //protected $storeInUtc; |
||
87 | protected $useCustomComposer = false; |
||
88 | protected $composerFile; |
||
89 | |||
90 | /** |
||
91 | * Displays the second install screen. |
||
92 | * |
||
93 | * @Action |
||
94 | * @Logged |
||
95 | * |
||
96 | * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only) |
||
97 | */ |
||
98 | public function configure($selfedit = 'false') |
||
99 | { |
||
100 | $this->selfedit = $selfedit; |
||
101 | |||
102 | if ($selfedit == 'true') { |
||
103 | $this->moufManager = MoufManager::getMoufManager(); |
||
104 | } else { |
||
105 | $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); |
||
106 | } |
||
107 | |||
108 | // Let's start by performing basic checks about the instances we assume to exist. |
||
109 | if (!$this->moufManager->instanceExists('dbalConnection')) { |
||
110 | $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."); |
||
111 | |||
112 | return; |
||
113 | } |
||
114 | |||
115 | if ($this->moufManager->has('tdbmConfiguration')) { |
||
116 | $tdbmConfiguration = $this->moufManager->getInstanceDescriptor('tdbmConfiguration'); |
||
117 | |||
118 | $this->beanNamespace = $tdbmConfiguration->getConstructorArgumentProperty('beanNamespace')->getValue(); |
||
119 | $this->daoNamespace = $tdbmConfiguration->getConstructorArgumentProperty('daoNamespace')->getValue(); |
||
120 | } else { |
||
121 | // Old TDBM 4.2 fallback |
||
122 | $this->daoNamespace = $this->moufManager->getVariable('tdbmDefaultDaoNamespace_tdbmService'); |
||
123 | $this->beanNamespace = $this->moufManager->getVariable('tdbmDefaultBeanNamespace_tdbmService'); |
||
124 | } |
||
125 | |||
126 | if ($this->daoNamespace == null && $this->beanNamespace == null) { |
||
127 | $classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json'); |
||
128 | |||
129 | $autoloadNamespaces = $classNameMapper->getManagedNamespaces(); |
||
130 | if ($autoloadNamespaces) { |
||
|
|||
131 | $this->autoloadDetected = true; |
||
132 | $rootNamespace = $autoloadNamespaces[0]; |
||
133 | $this->daoNamespace = $rootNamespace.'Dao'; |
||
134 | $this->beanNamespace = $rootNamespace.'Model'; |
||
135 | } else { |
||
136 | $this->autoloadDetected = false; |
||
137 | $this->daoNamespace = 'YourApplication\\Dao'; |
||
138 | $this->beanNamespace = 'YourApplication\\Model'; |
||
139 | } |
||
140 | } else { |
||
141 | $this->autoloadDetected = true; |
||
142 | } |
||
143 | $this->defaultPath = true; |
||
144 | $this->storePath = ''; |
||
145 | |||
146 | $this->castDatesToDateTime = true; |
||
147 | |||
148 | $this->content->addFile(__DIR__.'/../../../../views/installStep2.php', $this); |
||
149 | $this->template->toHtml(); |
||
150 | } |
||
151 | |||
152 | /** |
||
153 | * This action generates the TDBM instance, then the DAOs and Beans. |
||
154 | * |
||
155 | * @Action |
||
156 | * |
||
157 | * @param string $daonamespace |
||
158 | * @param string $beannamespace |
||
159 | * @param string $selfedit |
||
160 | * |
||
161 | * @throws \Mouf\MoufException |
||
162 | */ |
||
163 | public function generate($daonamespace, $beannamespace, /*$storeInUtc = 0,*/ $selfedit = 'false', $defaultPath = false, $storePath = '') |
||
230 | |||
231 | protected $errorMsg; |
||
232 | |||
233 | private function displayErrorMsg($msg) |
||
239 | } |
||
240 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.