| Conditions | 4 |
| Paths | 2 |
| Total Lines | 322 |
| Code Lines | 229 |
| Lines | 0 |
| Ratio | 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 |
||
| 41 | public function register(BaseApplication $app) |
||
| 42 | { |
||
| 43 | // Service |
||
| 44 | $app['eccube.service.system'] = $app->share(function () use ($app) { |
||
| 45 | return new \Eccube\Service\SystemService($app); |
||
| 46 | }); |
||
| 47 | $app['view'] = $app->share(function () use ($app) { |
||
| 48 | return $app['twig']; |
||
| 49 | }); |
||
| 50 | $app['eccube.service.cart'] = $app->share(function () use ($app) { |
||
| 51 | return new \Eccube\Service\CartService($app); |
||
| 52 | }); |
||
| 53 | $app['eccube.service.order'] = $app->share(function () use ($app) { |
||
| 54 | return new \Eccube\Service\OrderService($app); |
||
| 55 | }); |
||
| 56 | $app['eccube.service.tax_rule'] = $app->share(function () use ($app) { |
||
| 57 | return new \Eccube\Service\TaxRuleService($app['eccube.repository.tax_rule']); |
||
| 58 | }); |
||
| 59 | $app['eccube.service.plugin'] = $app->share(function () use ($app) { |
||
| 60 | return new \Eccube\Service\PluginService($app); |
||
| 61 | }); |
||
| 62 | $app['eccube.service.mail'] = $app->share(function () use ($app) { |
||
| 63 | return new \Eccube\Service\MailService($app); |
||
| 64 | }); |
||
| 65 | $app['eccube.service.csv.export'] = $app->share(function () use ($app) { |
||
| 66 | $csvService = new \Eccube\Service\CsvExportService(); |
||
| 67 | $csvService->setEntityManager($app['orm.em']); |
||
| 68 | $csvService->setConfig($app['config']); |
||
| 69 | $csvService->setCsvRepository($app['eccube.repository.csv']); |
||
| 70 | $csvService->setCsvTypeRepository($app['eccube.repository.master.csv_type']); |
||
| 71 | $csvService->setOrderRepository($app['eccube.repository.order']); |
||
| 72 | $csvService->setCustomerRepository($app['eccube.repository.customer']); |
||
| 73 | $csvService->setProductRepository($app['eccube.repository.product']); |
||
| 74 | |||
| 75 | return $csvService; |
||
| 76 | }); |
||
| 77 | $app['eccube.service.shopping'] = $app->share(function () use ($app) { |
||
| 78 | return new \Eccube\Service\ShoppingService($app, $app['eccube.service.cart'], $app['eccube.service.order']); |
||
| 79 | }); |
||
| 80 | |||
| 81 | // Repository |
||
| 82 | $app['eccube.repository.master.authority'] = $app->share(function () use ($app) { |
||
| 83 | return $app['orm.em']->getRepository('Eccube\Entity\Master\Authority'); |
||
| 84 | }); |
||
| 85 | $app['eccube.repository.master.tag'] = $app->share(function () use ($app) { |
||
| 86 | return $app['orm.em']->getRepository('Eccube\Entity\Master\Tag'); |
||
| 87 | }); |
||
| 88 | $app['eccube.repository.master.pref'] = $app->share(function () use ($app) { |
||
| 89 | return $app['orm.em']->getRepository('Eccube\Entity\Master\Pref'); |
||
| 90 | }); |
||
| 91 | $app['eccube.repository.master.sex'] = $app->share(function () use ($app) { |
||
| 92 | return $app['orm.em']->getRepository('Eccube\Entity\Master\Sex'); |
||
| 93 | }); |
||
| 94 | $app['eccube.repository.master.disp'] = $app->share(function () use ($app) { |
||
| 95 | return $app['orm.em']->getRepository('Eccube\Entity\Master\Disp'); |
||
| 96 | }); |
||
| 97 | $app['eccube.repository.master.product_type'] = $app->share(function () use ($app) { |
||
| 98 | return $app['orm.em']->getRepository('Eccube\Entity\Master\ProductType'); |
||
| 99 | }); |
||
| 100 | $app['eccube.repository.master.page_max'] = $app->share(function () use ($app) { |
||
| 101 | return $app['orm.em']->getRepository('Eccube\Entity\Master\PageMax'); |
||
| 102 | }); |
||
| 103 | $app['eccube.repository.master.order_status'] = $app->share(function () use ($app) { |
||
| 104 | return $app['orm.em']->getRepository('Eccube\Entity\Master\OrderStatus'); |
||
| 105 | }); |
||
| 106 | $app['eccube.repository.master.device_type'] = $app->share(function () use ($app) { |
||
| 107 | return $app['orm.em']->getRepository('Eccube\Entity\Master\DeviceType'); |
||
| 108 | }); |
||
| 109 | $app['eccube.repository.master.csv_type'] = $app->share(function () use ($app) { |
||
| 110 | return $app['orm.em']->getRepository('Eccube\Entity\Master\CsvType'); |
||
| 111 | }); |
||
| 112 | |||
| 113 | $app['eccube.repository.delivery'] = $app->share(function () use ($app) { |
||
| 114 | return $app['orm.em']->getRepository('Eccube\Entity\Delivery'); |
||
| 115 | }); |
||
| 116 | $app['eccube.repository.delivery_date'] = $app->share(function () use ($app) { |
||
| 117 | return $app['orm.em']->getRepository('Eccube\Entity\DeliveryDate'); |
||
| 118 | }); |
||
| 119 | $app['eccube.repository.delivery_fee'] = $app->share(function () use ($app) { |
||
| 120 | return $app['orm.em']->getRepository('Eccube\Entity\DeliveryFee'); |
||
| 121 | }); |
||
| 122 | $app['eccube.repository.delivery_time'] = $app->share(function () use ($app) { |
||
| 123 | return $app['orm.em']->getRepository('Eccube\Entity\DeliveryTime'); |
||
| 124 | }); |
||
| 125 | $app['eccube.repository.payment'] = $app->share(function () use ($app) { |
||
| 126 | return $app['orm.em']->getRepository('Eccube\Entity\Payment'); |
||
| 127 | }); |
||
| 128 | $app['eccube.repository.payment_option'] = $app->share(function () use ($app) { |
||
| 129 | return $app['orm.em']->getRepository('Eccube\Entity\PaymentOption'); |
||
| 130 | }); |
||
| 131 | $app['eccube.repository.category'] = $app->share(function () use ($app) { |
||
| 132 | return $app['orm.em']->getRepository('Eccube\Entity\Category'); |
||
| 133 | }); |
||
| 134 | $app['eccube.repository.customer'] = $app->share(function () use ($app) { |
||
| 135 | return $app['orm.em']->getRepository('Eccube\Entity\Customer'); |
||
| 136 | }); |
||
| 137 | $app['eccube.repository.news'] = $app->share(function () use ($app) { |
||
| 138 | return $app['orm.em']->getRepository('Eccube\Entity\News'); |
||
| 139 | }); |
||
| 140 | $app['eccube.repository.mail_history'] = $app->share(function () use ($app) { |
||
| 141 | return $app['orm.em']->getRepository('Eccube\Entity\MailHistory'); |
||
| 142 | }); |
||
| 143 | $app['eccube.repository.member'] = $app->share(function () use ($app) { |
||
| 144 | $memberRepository = $app['orm.em']->getRepository('Eccube\Entity\Member'); |
||
| 145 | $memberRepository->setEncoderFactorty($app['security.encoder_factory']); |
||
| 146 | return $memberRepository; |
||
| 147 | }); |
||
| 148 | $app['eccube.repository.order'] = $app->share(function () use ($app) { |
||
| 149 | return $app['orm.em']->getRepository('Eccube\Entity\Order'); |
||
| 150 | }); |
||
| 151 | $app['eccube.repository.product'] = $app->share(function () use ($app) { |
||
| 152 | $productRepository = $app['orm.em']->getRepository('Eccube\Entity\Product'); |
||
| 153 | return $productRepository; |
||
| 154 | }); |
||
| 155 | $app['eccube.repository.product_image'] = $app->share(function () use ($app) { |
||
| 156 | return $app['orm.em']->getRepository('Eccube\Entity\ProductImage'); |
||
| 157 | }); |
||
| 158 | $app['eccube.repository.product_class'] = $app->share(function () use ($app) { |
||
| 159 | return $app['orm.em']->getRepository('Eccube\Entity\ProductClass'); |
||
| 160 | }); |
||
| 161 | $app['eccube.repository.product_stock'] = $app->share(function () use ($app) { |
||
| 162 | return $app['orm.em']->getRepository('Eccube\Entity\ProductStock'); |
||
| 163 | }); |
||
| 164 | $app['eccube.repository.class_name'] = $app->share(function () use ($app) { |
||
| 165 | return $app['orm.em']->getRepository('Eccube\Entity\ClassName'); |
||
| 166 | }); |
||
| 167 | $app['eccube.repository.class_category'] = $app->share(function () use ($app) { |
||
| 168 | return $app['orm.em']->getRepository('Eccube\Entity\ClassCategory'); |
||
| 169 | }); |
||
| 170 | $app['eccube.repository.customer_favorite_product'] = $app->share(function () use ($app) { |
||
| 171 | return $app['orm.em']->getRepository('Eccube\Entity\CustomerFavoriteProduct'); |
||
| 172 | }); |
||
| 173 | $app['eccube.repository.base_info'] = $app->share(function () use ($app) { |
||
| 174 | return $app['orm.em']->getRepository('Eccube\Entity\BaseInfo'); |
||
| 175 | }); |
||
| 176 | $app['eccube.repository.tax_rule'] = $app->share(function () use ($app) { |
||
| 177 | $taxRuleRepository = $app['orm.em']->getRepository('Eccube\Entity\TaxRule'); |
||
| 178 | $taxRuleRepository->setApplication($app); |
||
| 179 | |||
| 180 | return $taxRuleRepository; |
||
| 181 | }); |
||
| 182 | $app['eccube.repository.page_layout'] = $app->share(function () use ($app) { |
||
| 183 | $pageLayoutRepository = $app['orm.em']->getRepository('Eccube\Entity\PageLayout'); |
||
| 184 | $pageLayoutRepository->setApplication($app); |
||
| 185 | |||
| 186 | return $pageLayoutRepository; |
||
| 187 | }); |
||
| 188 | $app['eccube.repository.block'] = $app->share(function () use ($app) { |
||
| 189 | $blockRepository = $app['orm.em']->getRepository('Eccube\Entity\Block'); |
||
| 190 | $blockRepository->setApplication($app); |
||
| 191 | |||
| 192 | return $blockRepository; |
||
| 193 | }); |
||
| 194 | $app['eccube.repository.order'] = $app->share(function () use ($app) { |
||
| 195 | $orderRepository = $app['orm.em']->getRepository('Eccube\Entity\Order'); |
||
| 196 | $orderRepository->setApplication($app); |
||
| 197 | |||
| 198 | return $orderRepository; |
||
| 199 | }); |
||
| 200 | $app['eccube.repository.customer_address'] = $app->share(function () use ($app) { |
||
| 201 | return $app['orm.em']->getRepository('Eccube\Entity\CustomerAddress'); |
||
| 202 | }); |
||
| 203 | $app['eccube.repository.shipping'] = $app->share(function () use ($app) { |
||
| 204 | return $app['orm.em']->getRepository('Eccube\Entity\Shipping'); |
||
| 205 | }); |
||
| 206 | $app['eccube.repository.customer_status'] = $app->share(function () use ($app) { |
||
| 207 | return $app['orm.em']->getRepository('Eccube\Entity\Master\CustomerStatus'); |
||
| 208 | }); |
||
| 209 | $app['eccube.repository.order_status'] = $app->share(function () use ($app) { |
||
| 210 | return $app['orm.em']->getRepository('Eccube\Entity\Master\OrderStatus'); |
||
| 211 | }); |
||
| 212 | $app['eccube.repository.mail_template'] = $app->share(function () use ($app) { |
||
| 213 | return $app['orm.em']->getRepository('Eccube\Entity\MailTemplate'); |
||
| 214 | }); |
||
| 215 | $app['eccube.repository.csv'] = $app->share(function () use ($app) { |
||
| 216 | return $app['orm.em']->getRepository('Eccube\Entity\Csv'); |
||
| 217 | }); |
||
| 218 | $app['eccube.repository.template'] = $app->share(function () use ($app) { |
||
| 219 | return $app['orm.em']->getRepository('Eccube\Entity\Template'); |
||
| 220 | }); |
||
| 221 | $app['eccube.repository.authority_role'] = $app->share(function () use ($app) { |
||
| 222 | return $app['orm.em']->getRepository('Eccube\Entity\AuthorityRole'); |
||
| 223 | }); |
||
| 224 | |||
| 225 | $app['paginator'] = $app->protect(function () { |
||
| 226 | return new \Knp\Component\Pager\Paginator(); |
||
| 227 | }); |
||
| 228 | |||
| 229 | $app['eccube.repository.help'] = $app->share(function () use ($app) { |
||
| 230 | return $app['orm.em']->getRepository('Eccube\Entity\Help'); |
||
| 231 | }); |
||
| 232 | $app['eccube.repository.plugin'] = $app->share(function () use ($app) { |
||
| 233 | return $app['orm.em']->getRepository('Eccube\Entity\Plugin'); |
||
| 234 | }); |
||
| 235 | $app['eccube.repository.plugin_event_handler'] = $app->share(function () use ($app) { |
||
| 236 | return $app['orm.em']->getRepository('Eccube\Entity\PluginEventHandler'); |
||
| 237 | }); |
||
| 238 | // em |
||
| 239 | if (isset($app['orm.em'])) { |
||
| 240 | $app['orm.em'] = $app->share($app->extend('orm.em', function (\Doctrine\ORM\EntityManager $em, \Silex\Application $app) { |
||
| 241 | // tax_rule |
||
| 242 | $taxRuleRepository = $em->getRepository('Eccube\Entity\TaxRule'); |
||
| 243 | $taxRuleRepository->setApplication($app); |
||
| 244 | $taxRuleService = new \Eccube\Service\TaxRuleService($taxRuleRepository); |
||
| 245 | $em->getEventManager()->addEventSubscriber(new \Eccube\Doctrine\EventSubscriber\TaxRuleEventSubscriber($taxRuleService)); |
||
| 246 | |||
| 247 | // save |
||
| 248 | $saveEventSubscriber = new \Eccube\Doctrine\EventSubscriber\SaveEventSubscriber($app); |
||
| 249 | $em->getEventManager()->addEventSubscriber($saveEventSubscriber); |
||
| 250 | |||
| 251 | // filters |
||
| 252 | $config = $em->getConfiguration(); |
||
| 253 | $config->addFilter("soft_delete", '\Eccube\Doctrine\Filter\SoftDeleteFilter'); |
||
| 254 | $config->addFilter("nostock_hidden", '\Eccube\Doctrine\Filter\NoStockHiddenFilter'); |
||
| 255 | $config->addFilter("incomplete_order_status_hidden", '\Eccube\Doctrine\Filter\OrderStatusFilter'); |
||
| 256 | $em->getFilters()->enable('soft_delete'); |
||
| 257 | |||
| 258 | return $em; |
||
| 259 | })); |
||
| 260 | } |
||
| 261 | |||
| 262 | // Form\Type |
||
| 263 | $app['form.type.extensions'] = $app->share($app->extend('form.type.extensions', function ($extensions) use ($app) { |
||
| 264 | $extensions[] = new \Eccube\Form\Extension\HelpTypeExtension(); |
||
| 265 | $extensions[] = new \Eccube\Form\Extension\FreezeTypeExtension(); |
||
| 266 | |||
| 267 | return $extensions; |
||
| 268 | })); |
||
| 269 | $app['form.types'] = $app->share($app->extend('form.types', function ($types) use ($app) { |
||
| 270 | $types[] = new \Eccube\Form\Type\NameType($app['config']); |
||
| 271 | $types[] = new \Eccube\Form\Type\KanaType($app['config']); |
||
| 272 | $types[] = new \Eccube\Form\Type\TelType($app['config']); |
||
| 273 | $types[] = new \Eccube\Form\Type\FaxType(); // 削除予定 |
||
| 274 | $types[] = new \Eccube\Form\Type\ZipType($app['config']); |
||
| 275 | $types[] = new \Eccube\Form\Type\AddressType($app['config']); |
||
| 276 | $types[] = new \Eccube\Form\Type\RepeatedEmailType(); |
||
| 277 | $types[] = new \Eccube\Form\Type\RepeatedPasswordType($app['config']); |
||
| 278 | $types[] = new \Eccube\Form\Type\PriceType($app['config']); |
||
| 279 | |||
| 280 | $types[] = new \Eccube\Form\Type\MasterType(); |
||
| 281 | $types[] = new \Eccube\Form\Type\Master\JobType(); |
||
| 282 | $types[] = new \Eccube\Form\Type\Master\CustomerStatusType(); |
||
| 283 | $types[] = new \Eccube\Form\Type\Master\OrderStatusType(); |
||
| 284 | $types[] = new \Eccube\Form\Type\Master\CalcRuleType(); |
||
| 285 | $types[] = new \Eccube\Form\Type\Master\SexType(); |
||
| 286 | $types[] = new \Eccube\Form\Type\Master\DispType(); |
||
| 287 | $types[] = new \Eccube\Form\Type\Master\PrefType(); |
||
| 288 | $types[] = new \Eccube\Form\Type\Master\ProductTypeType(); |
||
| 289 | $types[] = new \Eccube\Form\Type\Master\ProductListMaxType(); |
||
| 290 | $types[] = new \Eccube\Form\Type\Master\ProductListOrderByType(); |
||
| 291 | $types[] = new \Eccube\Form\Type\Master\PageMaxType(); |
||
| 292 | $types[] = new \Eccube\Form\Type\Master\CsvType(); |
||
| 293 | $types[] = new \Eccube\Form\Type\Master\DeliveryDateType(); |
||
| 294 | $types[] = new \Eccube\Form\Type\Master\PaymentType(); |
||
| 295 | $types[] = new \Eccube\Form\Type\Master\MailTemplateType(); |
||
| 296 | $types[] = new \Eccube\Form\Type\Master\CategoryType(); |
||
| 297 | |||
| 298 | $types[] = new \Eccube\Form\Type\CustomerType($app); // 削除予定 |
||
| 299 | |||
| 300 | if (isset($app['security']) && isset($app['eccube.repository.customer_favorite_product'])) { |
||
| 301 | $types[] = new \Eccube\Form\Type\AddCartType($app['config'], $app['security'], $app['eccube.repository.customer_favorite_product']); |
||
| 302 | } |
||
| 303 | $types[] = new \Eccube\Form\Type\SearchProductType(); |
||
| 304 | $types[] = new \Eccube\Form\Type\OrderSearchType($app); |
||
| 305 | $types[] = new \Eccube\Form\Type\ShippingItemType($app); |
||
| 306 | $types[] = new \Eccube\Form\Type\ShippingMultipleType($app); |
||
| 307 | $types[] = new \Eccube\Form\Type\ShippingMultipleItemType($app); |
||
| 308 | $types[] = new \Eccube\Form\Type\ShoppingType(); |
||
| 309 | |||
| 310 | // front |
||
| 311 | $types[] = new \Eccube\Form\Type\Front\EntryType($app['config']); |
||
| 312 | $types[] = new \Eccube\Form\Type\Front\ContactType($app['config']); |
||
| 313 | $types[] = new \Eccube\Form\Type\Front\NonMemberType($app['config']); |
||
| 314 | $types[] = new \Eccube\Form\Type\Front\ShoppingShippingType(); |
||
| 315 | $types[] = new \Eccube\Form\Type\Front\CustomerAddressType($app['config']); |
||
| 316 | $types[] = new \Eccube\Form\Type\Front\ForgotType(); |
||
| 317 | $types[] = new \Eccube\Form\Type\Front\CustomerLoginType($app['session']); |
||
| 318 | |||
| 319 | // admin |
||
| 320 | $types[] = new \Eccube\Form\Type\Admin\LoginType($app['session']); |
||
| 321 | $types[] = new \Eccube\Form\Type\Admin\ProductType($app); |
||
| 322 | $types[] = new \Eccube\Form\Type\Admin\ProductClassType($app); |
||
| 323 | $types[] = new \Eccube\Form\Type\Admin\SearchProductType($app); |
||
| 324 | $types[] = new \Eccube\Form\Type\Admin\SearchCustomerType($app['config']); |
||
| 325 | $types[] = new \Eccube\Form\Type\Admin\SearchOrderType($app['config']); |
||
| 326 | $types[] = new \Eccube\Form\Type\Admin\CustomerType($app['config']); |
||
| 327 | $types[] = new \Eccube\Form\Type\Admin\ClassNameType($app['config']); |
||
| 328 | $types[] = new \Eccube\Form\Type\Admin\ClassCategoryType($app['config']); |
||
| 329 | $types[] = new \Eccube\Form\Type\Admin\CategoryType($app['config']); |
||
| 330 | $types[] = new \Eccube\Form\Type\Admin\MemberType($app['config']); |
||
| 331 | $types[] = new \Eccube\Form\Type\Admin\AuthorityRoleType($app['config']); |
||
| 332 | $types[] = new \Eccube\Form\Type\Admin\PageLayoutType(); |
||
| 333 | $types[] = new \Eccube\Form\Type\Admin\NewsType($app['config']); |
||
| 334 | $types[] = new \Eccube\Form\Type\Admin\TemplateType($app['config']); |
||
| 335 | $types[] = new \Eccube\Form\Type\Admin\SecurityType($app); |
||
| 336 | $types[] = new \Eccube\Form\Type\Admin\CsvImportType($app); |
||
| 337 | $types[] = new \Eccube\Form\Type\Admin\ShopMasterType($app['config']); |
||
| 338 | $types[] = new \Eccube\Form\Type\Admin\TradelawType($app['config']); |
||
| 339 | $types[] = new \Eccube\Form\Type\Admin\OrderType($app); |
||
| 340 | $types[] = new \Eccube\Form\Type\Admin\OrderDetailType($app); |
||
| 341 | $types[] = new \Eccube\Form\Type\Admin\ShippingType($app); |
||
| 342 | $types[] = new \Eccube\Form\Type\Admin\ShipmentItemType($app); |
||
| 343 | $types[] = new \Eccube\Form\Type\Admin\PaymentRegisterType(); |
||
| 344 | $types[] = new \Eccube\Form\Type\Admin\TaxRuleType(); |
||
| 345 | $types[] = new \Eccube\Form\Type\Admin\MainEditType($app); |
||
| 346 | $types[] = new \Eccube\Form\Type\Admin\MailType(); |
||
| 347 | $types[] = new \Eccube\Form\Type\Admin\CustomerAgreementType($app); |
||
| 348 | $types[] = new \Eccube\Form\Type\Admin\BlockType($app); |
||
| 349 | $types[] = new \Eccube\Form\Type\Admin\DeliveryType(); |
||
| 350 | $types[] = new \Eccube\Form\Type\Admin\DeliveryFeeType(); |
||
| 351 | $types[] = new \Eccube\Form\Type\Admin\DeliveryTimeType($app['config']); |
||
| 352 | $types[] = new \Eccube\Form\Type\Admin\LogType($app['config']); |
||
| 353 | |||
| 354 | $types[] = new \Eccube\Form\Type\Admin\MasterdataType($app); |
||
| 355 | $types[] = new \Eccube\Form\Type\Admin\MasterdataEditType($app); |
||
| 356 | |||
| 357 | $types[] = new \Eccube\Form\Type\Admin\PluginLocalInstallType(); |
||
| 358 | $types[] = new \Eccube\Form\Type\Admin\PluginManagementType(); |
||
| 359 | |||
| 360 | return $types; |
||
| 361 | })); |
||
| 362 | } |
||
| 363 | |||
| 375 |