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