| Conditions | 6 |
| Paths | 4 |
| Total Lines | 57 |
| Code Lines | 34 |
| 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 |
||
| 54 | public function updateConfiguration() |
||
| 55 | { |
||
| 56 | $configName = 'translation'; |
||
| 57 | $transConfigOld = $this->configDumper->getConfiguration($configName); |
||
| 58 | $transConfigNew = [ |
||
| 59 | 'configs' => [ |
||
| 60 | 'zikula' => $transConfigOld['configs']['zikula'], |
||
| 61 | 'extension' => $transConfigOld['configs']['extension'] |
||
| 62 | ] |
||
| 63 | ]; |
||
| 64 | |||
| 65 | if (file_exists($this->kernel->getProjectDir() . '/src/system')) { |
||
| 66 | // development system: core bundles and system modules are in "src/" |
||
| 67 | $transConfigNew['configs']['zikula']['dirs'] = [ |
||
| 68 | '%kernel.project_dir%/templates', |
||
| 69 | '%kernel.project_dir%/src/system', |
||
| 70 | '%kernel.project_dir%/src/Zikula' |
||
| 71 | ]; |
||
| 72 | // note we can not set this in a distribution system when core components are in "vendor/" |
||
| 73 | } |
||
| 74 | |||
| 75 | if ($this->installed) { |
||
| 76 | $configTemplate = [ |
||
| 77 | 'excluded_names' => ['*TestCase.php', '*Test.php'], |
||
| 78 | 'excluded_dirs' => ['vendor'], |
||
| 79 | 'output_format' => 'yaml', |
||
| 80 | 'local_file_storage_options' => [ |
||
| 81 | 'default_output_format' => 'yaml' |
||
| 82 | ] |
||
| 83 | ]; |
||
| 84 | foreach ($this->kernel->getModules() as $bundle) { |
||
| 85 | if ($this->kernel->isCoreExtension($bundle->getName())) { |
||
| 86 | continue; |
||
| 87 | } |
||
| 88 | $bundleConfig = $configTemplate; |
||
| 89 | $translationDirectory = $bundle->getPath() . '/Resources/translations'; |
||
| 90 | $bundleConfig['output_dir'] = $translationDirectory; |
||
| 91 | $bundleConfig['external_translations_dir'] = $translationDirectory; |
||
| 92 | $transConfigNew['configs'][mb_strtolower($bundle->getName())] = $bundleConfig; |
||
| 93 | } |
||
| 94 | foreach ($this->kernel->getThemes() as $bundle) { |
||
| 95 | // lets include core themes as they need translation as all other themes, too |
||
| 96 | // (/system is included in "zikula" config while /themes is not) |
||
| 97 | /*if (in_array($bundle->getName(), ['ZikulaBootstrapTheme', 'ZikulaAtomTheme', 'ZikulaPrinterTheme', 'ZikulaRssTheme'], true)) { |
||
| 98 | continue; |
||
| 99 | }*/ |
||
| 100 | $bundleConfig = $configTemplate; |
||
| 101 | $translationDirectory = $bundle->getPath() . '/Resources/translations'; |
||
| 102 | $bundleConfig['output_dir'] = $translationDirectory; |
||
| 103 | $bundleConfig['external_translations_dir'] = $translationDirectory; |
||
| 104 | $transConfigNew['configs'][mb_strtolower($bundle->getName())] = $bundleConfig; |
||
| 105 | } |
||
| 106 | } |
||
| 107 | |||
| 108 | $this->configDumper->setConfiguration($configName, $transConfigNew); |
||
| 109 | |||
| 110 | $this->cacheClearer->clear('symfony'); |
||
| 111 | } |
||
| 113 |