| Conditions | 4 |
| Paths | 6 |
| Total Lines | 85 |
| Code Lines | 70 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 199 | public function defaultdata() |
||
| 200 | { |
||
| 201 | // create the default block positions - left, right and center for the traditional 3 column layout |
||
| 202 | $positions = [ |
||
| 203 | 'left' => $this->__('Left blocks'), |
||
| 204 | 'right' => $this->__('Right blocks'), |
||
| 205 | 'center' => $this->__('Center blocks'), |
||
| 206 | 'search' => $this->__('Search block'), |
||
| 207 | 'header' => $this->__('Header block'), |
||
| 208 | 'footer' => $this->__('Footer block'), |
||
| 209 | 'topnav' => $this->__('Top navigation block'), |
||
| 210 | 'bottomnav' => $this->__('Bottom navigation block'), |
||
| 211 | ]; |
||
| 212 | foreach ($positions as $name => $description) { |
||
| 213 | $positions[$name] = new BlockPositionEntity(); |
||
| 214 | $positions[$name]->setName($name); |
||
| 215 | $positions[$name]->setDescription($description); |
||
| 216 | $this->entityManager->persist($positions[$name]); |
||
| 217 | } |
||
| 218 | $this->entityManager->flush(); |
||
| 219 | |||
| 220 | $hellomessage = $this->__('<p><a href="http://zikula.org/">Zikula</a> is a content management system (CMS) and application framework. It is secure and stable, and is a good choice for sites with a large volume of traffic.</p><p>With Zikula:</p><ul><li>you can customise all aspects of the site\'s appearance through themes, with support for CSS style sheets, JavaScript, Flash and all other modern web development technologies;</li><li>you can mark content as being suitable for either a single language or for all languages, and can control all aspects of localisation and internationalisation of your site;</li><li>you can be sure that your pages will display properly in all browsers, thanks to Zikula\'s full compliance with W3C HTML standards;</li><li>you get a standard application-programming interface (API) that lets you easily augment your site\'s functionality through modules, blocks and other extensions;</li><li>you can get help and support from the Zikula community of webmasters and developers at <a href="http://www.zikula.org">zikula.org</a>.</li></ul><p>Enjoy using Zikula!</p><p><strong>The Zikula team</strong></p><p><em>Note: Zikula is Free Open Source Software (FOSS) licensed under the GNU General Public License.</em></p>'); |
||
| 221 | |||
| 222 | $blocks = []; |
||
| 223 | $extensionRepo = $this->entityManager->getRepository('\Zikula\ExtensionsModule\Entity\ExtensionEntity'); |
||
| 224 | $blocksModuleEntity = $extensionRepo->findOneBy(['name' => 'ZikulaBlocksModule']); |
||
| 225 | $searchModuleEntity = $extensionRepo->findOneBy(['name' => 'ZikulaSearchModule']); |
||
| 226 | $usersModuleEntity = $extensionRepo->findOneBy(['name' => 'ZikulaUsersModule']); |
||
| 227 | $blocks[] = [ |
||
| 228 | 'bkey' => 'ZikulaSearchModule:\Zikula\SearchModule\Block\SearchBlock', |
||
| 229 | 'blocktype' => 'Search', |
||
| 230 | 'language' => '', |
||
| 231 | 'module' => $searchModuleEntity, |
||
| 232 | 'title' => $this->__('Search box'), |
||
| 233 | 'description' => $this->__('Search block'), |
||
| 234 | 'properties' => [ |
||
| 235 | 'displaySearchBtn' => true, |
||
| 236 | 'active' => ['ZikulaUsersModule' => 1] |
||
| 237 | ], |
||
| 238 | 'position' => $positions['left'] |
||
| 239 | ]; |
||
| 240 | $blocks[] = [ |
||
| 241 | 'bkey' => 'ZikulaBlocksModule:\Zikula\BlocksModule\Block\HtmlBlock', |
||
| 242 | 'blocktype' => 'Html', |
||
| 243 | 'language' => '', |
||
| 244 | 'module' => $blocksModuleEntity, |
||
| 245 | 'title' => $this->__("This site is powered by Zikula!"), |
||
| 246 | 'description' => $this->__('HTML block'), |
||
| 247 | 'properties' => ['content' => $hellomessage], |
||
| 248 | 'position' => $positions['center'] |
||
| 249 | ]; |
||
| 250 | $blocks[] = [ |
||
| 251 | 'bkey' => 'ZikulaUsersModule:\Zikula\UsersModule\Block\LoginBlock', |
||
| 252 | 'blocktype' => 'Login', |
||
| 253 | 'language' => '', |
||
| 254 | 'module' => $usersModuleEntity, |
||
| 255 | 'title' => $this->__('User log-in'), |
||
| 256 | 'description' => $this->__('Login block'), |
||
| 257 | 'position' => $positions['topnav'], |
||
| 258 | 'order' => 1, |
||
| 259 | 'filters' => [[ |
||
| 260 | 'attribute' => '_route', |
||
| 261 | 'queryParameter' => null, |
||
| 262 | 'comparator' => '!=', |
||
| 263 | 'value' => 'zikulausersmodule_access_login' |
||
| 264 | ]] |
||
| 265 | ]; |
||
| 266 | |||
| 267 | foreach ($blocks as $block) { |
||
| 268 | $blockEntity = new BlockEntity(); |
||
| 269 | $position = $block['position']; |
||
| 270 | $sortOrder = !empty($block['order']) ? $block['order'] : 0; |
||
| 271 | unset($block['position'], $block['order']); |
||
| 272 | $blockEntity->merge($block); |
||
| 273 | $this->entityManager->persist($blockEntity); |
||
| 274 | $placement = new BlockPlacementEntity(); |
||
| 275 | $placement->setBlock($blockEntity); |
||
| 276 | $placement->setPosition($position); |
||
| 277 | $placement->setSortorder($sortOrder); |
||
| 278 | $this->entityManager->persist($placement); |
||
| 279 | } |
||
| 280 | $this->entityManager->flush(); |
||
| 281 | |||
| 282 | return; |
||
| 283 | } |
||
| 284 | |||
| 290 |