| Conditions | 16 |
| Paths | 630 |
| Total Lines | 77 |
| Code Lines | 48 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 177 | public function executeCoreMetaUpgrade($currentCoreVersion): bool |
||
| 178 | { |
||
| 179 | /** |
||
| 180 | * NOTE: There are *intentionally* no `break` statements within each case here so that the process continues |
||
| 181 | * through each case until the end. |
||
| 182 | */ |
||
| 183 | switch ($currentCoreVersion) { |
||
| 184 | case '1.4.3': |
||
| 185 | $this->install('ZikulaMenuModule'); |
||
| 186 | $this->reSyncAndActivate(); |
||
| 187 | $this->adminCategoryHelper->setCategory('ZikulaMenuModule', $this->translator->trans('Content')); |
||
| 188 | case '1.4.4': |
||
| 189 | // nothing |
||
| 190 | case '1.4.5': |
||
| 191 | // Menu module was introduced in 1.4.4 but not installed on upgrade |
||
| 192 | $schemaManager = $this->managerRegistry->getConnection()->getSchemaManager(); |
||
| 193 | if (!$schemaManager->tablesExist(['menu_items'])) { |
||
| 194 | $this->install('ZikulaMenuModule'); |
||
| 195 | $this->reSyncAndActivate(); |
||
| 196 | $this->adminCategoryHelper->setCategory('ZikulaMenuModule', $this->translator->trans('Content')); |
||
| 197 | } |
||
| 198 | case '1.4.6': |
||
| 199 | // nothing needed |
||
| 200 | case '1.4.7': |
||
| 201 | // nothing needed |
||
| 202 | case '1.5.0': |
||
| 203 | // nothing needed |
||
| 204 | case '1.9.99': |
||
| 205 | // upgrades required for 2.0.0 |
||
| 206 | foreach (['objectdata_attributes', 'objectdata_log', 'objectdata_meta', 'workflows'] as $table) { |
||
| 207 | $sql = "DROP TABLE ${table};"; |
||
| 208 | /** @var \Doctrine\DBAL\Driver\PDOConnection $connection */ |
||
| 209 | $connection = $this->managerRegistry->getConnection(); |
||
| 210 | $stmt = $connection->prepare($sql); |
||
| 211 | $stmt->execute(); |
||
| 212 | $stmt->closeCursor(); |
||
| 213 | } |
||
| 214 | $this->variableApi->del(VariableApi::CONFIG, 'metakeywords'); |
||
| 215 | $this->variableApi->del(VariableApi::CONFIG, 'startpage'); |
||
| 216 | $this->variableApi->del(VariableApi::CONFIG, 'startfunc'); |
||
| 217 | $this->variableApi->del(VariableApi::CONFIG, 'starttype'); |
||
| 218 | if ('userdata' === $this->yamlHelper->getParameter('datadir')) { |
||
| 219 | $this->yamlHelper->setParameter('datadir', 'public/uploads'); |
||
| 220 | $fs = new Filesystem(); |
||
| 221 | $src = $this->kernel->getProjectDir(); |
||
| 222 | try { |
||
| 223 | if ($fs->exists($src . '/userdata')) { |
||
| 224 | $fs->mirror($src . '/userdata', $src . '/public/uploads'); |
||
| 225 | } |
||
| 226 | } catch (\Exception $exception) { |
||
| 227 | $this->session->getFlashBag()->add( |
||
| 228 | 'info', |
||
| 229 | 'Attempt to copy files from `userdata` to `public/uploads` failed. You must manually copy the contents.' |
||
| 230 | ); |
||
| 231 | } |
||
| 232 | } |
||
| 233 | // remove legacy blocks |
||
| 234 | $blocksToRemove = $this->managerRegistry->getRepository(BlockEntity::class)->findBy(['blocktype' => ['Extmenu', 'Menutree', 'Menu']]); |
||
| 235 | foreach ($blocksToRemove as $block) { |
||
| 236 | $this->managerRegistry->getManager()->remove($block); |
||
| 237 | } |
||
| 238 | $this->managerRegistry->getManager()->flush(); |
||
| 239 | case '2.0.15': |
||
| 240 | // nothing |
||
| 241 | case '3.0.0': |
||
| 242 | // current version - cannot perform anything yet |
||
| 243 | } |
||
| 244 | |||
| 245 | // always do this |
||
| 246 | $this->reSyncAndActivate(); |
||
| 247 | // set default themes to ZikulaBootstrapTheme |
||
| 248 | $this->variableApi->set(VariableApi::CONFIG, 'Default_Theme', 'ZikulaBootstrapTheme'); |
||
| 249 | $this->variableApi->set('ZikulaAdminModule', 'admintheme', ''); |
||
| 250 | // unset start page information to avoid missing module errors |
||
| 251 | $this->variableApi->set(VariableApi::CONFIG, 'startController_en', ''); |
||
| 252 | |||
| 253 | return true; |
||
| 254 | } |
||
| 256 |