FrontControllerProvider::connect()   B
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 97
Code Lines 66

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 5.4784

Importance

Changes 0
Metric Value
cc 2
eloc 66
nc 2
nop 1
dl 0
loc 97
rs 8.3604
c 0
b 0
f 0
ccs 3
cts 66
cp 0.0455
crap 5.4784

How to fix   Long Method   

Long Method

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:

1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * This program is free software; you can redistribute it and/or
11
 * modify it under the terms of the GNU General Public License
12
 * as published by the Free Software Foundation; either version 2
13
 * of the License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23
 */
24
25
namespace Eccube\ControllerProvider;
26
27
use Silex\Application;
28
use Silex\ControllerProviderInterface;
29
30
class FrontControllerProvider implements ControllerProviderInterface
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
31
{
32 626
    public function connect(Application $app)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
33
    {
34
        $c = $app['controllers_factory'];
35
36
        // 強制SSL
37
        if ($app['config']['force_ssl'] == \Eccube\Common\Constant::ENABLED) {
38
            $c->requireHttps();
39
        }
40
41
        // user定義
42
        $c->match('/'.$app['config']['user_data_route'].'/{route}', '\Eccube\Controller\UserDataController::index')->assert('route', '([0-9a-zA-Z_\-]+\/?)+(?<!\/)')->bind('user_data');
43
44
        // root
45
        $c->match('/', '\Eccube\Controller\TopController::index')->bind('homepage');
46
        $c->match('/', '\Eccube\Controller\TopController::index')->bind('top'); // deprecated since 3.0.0, to be removed in 3.1
47
        $c->match('/', '\Eccube\Controller\TopController::index')->bind('index'); // deprecated since 3.0.0, to be removed in 3.1
48
49
        // cart
50
        $c->match('/cart', '\Eccube\Controller\CartController::index')->bind('cart');
51
        $c->post('/cart/add', '\Eccube\Controller\CartController::add')->bind('cart_add');
52
        $c->put('/cart/up/{productClassId}', '\Eccube\Controller\CartController::up')->bind('cart_up')->assert('productClassId', '\d+');
53
        $c->put('/cart/down/{productClassId}', '\Eccube\Controller\CartController::down')->bind('cart_down')->assert('productClassId', '\d+');
54
        // setquantity deprecated since 3.0.0, to be removed in 3.1
55
        $c->put('/cart/setQuantity/{productClassId}/{quantity}', '\Eccube\Controller\CartController::setQuantity')->bind('cart_set_quantity')->assert('productClassId', '\d+')->assert('quantity', '\d+');
56
        $c->put('/cart/remove/{productClassId}', '\Eccube\Controller\CartController::remove')->bind('cart_remove')->assert('productClassId', '\d+');
57
        $c->match('/cart/buystep', '\Eccube\Controller\CartController::buystep')->bind('cart_buystep');
58
59
        // contact
60
        $c->match('/contact', '\Eccube\Controller\ContactController::index')->bind('contact');
61
        $c->match('/contact/complete', '\Eccube\Controller\ContactController::complete')->bind('contact_complete');
62
63
        // entry
64
        $c->match('/entry', '\Eccube\Controller\EntryController::index')->bind('entry');
65
        $c->match('/entry/complete', '\Eccube\Controller\EntryController::complete')->bind('entry_complete');
66
        $c->match('/entry/activate/{secret_key}', '\Eccube\Controller\EntryController::activate')->bind('entry_activate');
67
68
        // forgot
69
        $c->match('/forgot', '\Eccube\Controller\ForgotController::index')->bind('forgot');
70
        $c->match('/forgot/complete', '\Eccube\Controller\ForgotController::complete')->bind('forgot_complete');
71
        $c->match('/forgot/reset/{reset_key}', '\Eccube\Controller\ForgotController::reset')->bind('forgot_reset');
72
73
        // block
74
        $c->match('/block/category', '\Eccube\Controller\Block\CategoryController::index')->bind('block_category');
75
        $c->match('/block/cart', '\Eccube\Controller\Block\CartController::index')->bind('block_cart');
76
        $c->match('/block/search_product', '\Eccube\Controller\Block\SearchProductController::index')->bind('block_search_product');
77
        $c->match('/block/news', '\Eccube\Controller\Block\NewsController::index')->bind('block_news');
78
        $c->match('/block/login', '\Eccube\Controller\Block\LoginController::index')->bind('block_login');
79
80
        // 特定商取引 order -> help/traderaw
81
        $c->match('/help/about', '\Eccube\Controller\HelpController::about')->bind('help_about');
82
        $c->match('/help/guide', '\Eccube\Controller\HelpController::guide')->bind('help_guide');
83
        $c->match('/help/privacy', '\Eccube\Controller\HelpController::privacy')->bind('help_privacy');
84
        $c->match('/help/tradelaw', '\Eccube\Controller\HelpController::tradelaw')->bind('help_tradelaw');
85
        $c->match('/help/agreement', '\Eccube\Controller\HelpController::agreement')->bind('help_agreement');
86
87
        // mypage
88
        $c->match('/mypage', '\Eccube\Controller\Mypage\MypageController::index')->bind('mypage');
89
        $c->match('/mypage/login', '\Eccube\Controller\Mypage\MypageController::login')->bind('mypage_login');
90
        $c->match('/mypage/change', '\Eccube\Controller\Mypage\ChangeController::index')->bind('mypage_change');
91
        $c->match('/mypage/change_complete', '\Eccube\Controller\Mypage\ChangeController::complete')->bind('mypage_change_complete');
92
93
        $c->match('/mypage/delivery', '\Eccube\Controller\Mypage\DeliveryController::index')->bind('mypage_delivery');
94
        $c->match('/mypage/delivery/new', '\Eccube\Controller\Mypage\DeliveryController::edit')->bind('mypage_delivery_new');
95
        $c->match('/mypage/delivery/{id}/edit', '\Eccube\Controller\Mypage\DeliveryController::edit')->assert('id', '\d+')->bind('mypage_delivery_edit');
96
        $c->delete('/mypage/delivery/{id}/delete', '\Eccube\Controller\Mypage\DeliveryController::delete')->assert('id', '\d+')->bind('mypage_delivery_delete');
97
98
        $c->match('/mypage/favorite', '\Eccube\Controller\Mypage\MypageController::favorite')->bind('mypage_favorite');
99
        $c->delete('/mypage/favorite/{id}/delete', '\Eccube\Controller\Mypage\MypageController::delete')->assert('id', '\d+')->bind('mypage_favorite_delete');
100
        $c->match('/mypage/history/{id}', '\Eccube\Controller\Mypage\MypageController::history')->bind('mypage_history')->assert('id', '\d+');
101
        $c->put('/mypage/order/{id}', '\Eccube\Controller\Mypage\MypageController::order')->bind('mypage_order')->assert('id', '\d+');
102
        $c->match('/mypage/withdraw', '\Eccube\Controller\Mypage\WithdrawController::index')->bind('mypage_withdraw');
103
        $c->match('/mypage/withdraw_complete', '\Eccube\Controller\Mypage\WithdrawController::complete')->bind('mypage_withdraw_complete');
104
105
        // products
106
        $c->match('/products/list', '\Eccube\Controller\ProductController::index')->bind('product_list');
107
        $c->match('/products/detail/{id}', '\Eccube\Controller\ProductController::detail')->bind('product_detail')->assert('id', '\d+');
108
109
        // shopping
110
        $c->match('/shopping', '\Eccube\Controller\ShoppingController::index')->bind('shopping');
111
        $c->match('/shopping/confirm', '\Eccube\Controller\ShoppingController::confirm')->bind('shopping_confirm');
112
        $c->match('/shopping/delivery', '\Eccube\Controller\ShoppingController::delivery')->bind('shopping_delivery');
113
        $c->match('/shopping/payment', '\Eccube\Controller\ShoppingController::payment')->bind('shopping_payment');
114
        $c->match('/shopping/shipping_change/{id}', '\Eccube\Controller\ShoppingController::shippingChange')->assert('id', '\d+')->bind('shopping_shipping_change');
115
        $c->match('/shopping/shipping/{id}', '\Eccube\Controller\ShoppingController::shipping')->assert('id', '\d+')->bind('shopping_shipping');
116
        $c->match('/shopping/shipping_edit_change/{id}', '\Eccube\Controller\ShoppingController::shippingEditChange')->assert('id', '\d+')->bind('shopping_shipping_edit_change');
117
        $c->match('/shopping/shipping_edit/{id}', '\Eccube\Controller\ShoppingController::shippingEdit')->assert('id', '\d+')->bind('shopping_shipping_edit');
118
        $c->match('/shopping/complete', '\Eccube\Controller\ShoppingController::complete')->bind('shopping_complete');
119
        $c->match('/shopping/login', '\Eccube\Controller\ShoppingController::login')->bind('shopping_login');
120
        $c->match('/shopping/nonmember', '\Eccube\Controller\ShoppingController::nonmember')->bind('shopping_nonmember');
121
        $c->match('/shopping/customer', '\Eccube\Controller\ShoppingController::customer')->bind('shopping_customer');
122
        $c->match('/shopping/shopping_error', '\Eccube\Controller\ShoppingController::shoppingError')->bind('shopping_error');
123
        $c->match('/shopping/shipping_multiple_change', '\Eccube\Controller\ShoppingController::shippingMultipleChange')->bind('shopping_shipping_multiple_change');
124
        $c->match('/shopping/shipping_multiple', '\Eccube\Controller\ShoppingController::shippingMultiple')->bind('shopping_shipping_multiple');
125
        $c->match('/shopping/shipping_multiple_edit', '\Eccube\Controller\ShoppingController::shippingMultipleEdit')->bind('shopping_shipping_multiple_edit');
126 626
127 626
        return $c;
128
    }
129
}
130