File tree 9 files changed +78
-1
lines changed
9 files changed +78
-1
lines changed Original file line number Diff line number Diff line change 37
37
"symfony/dependency-injection" : " ^5.4 || ^6.4 || ^7.0" ,
38
38
"symfony/event-dispatcher" : " ^5.4 || ^6.4 || ^7.0" ,
39
39
"symfony/form" : " ^5.4 || ^6.4 || ^7.0" ,
40
+ "symfony/http-foundation" : " ^5.4 || ^6.4 || ^7.0" ,
40
41
"symfony/http-kernel" : " ^5.4 || ^6.4 || ^7.0" ,
41
42
"symfony/messenger" : " ^5.4 || ^6.4 || ^7.0" ,
42
43
"symfony/options-resolver" : " ^5.4 || ^6.4 || ^7.0" ,
44
+ "symfony/routing" : " ^5.4 || ^6.4 || ^7.0" ,
43
45
"symfony/uid" : " ^5.4 || ^6.4 || ^7.0" ,
44
46
"symfony/validator" : " ^5.4 || ^6.4 || ^7.0" ,
45
47
"symfony/workflow" : " ^5.4 || ^6.4 || ^7.0" ,
Original file line number Diff line number Diff line change 11
11
"badge": "1.x"
12
12
}
13
13
},
14
- "minMsi": 100.00 ,
14
+ "minMsi": 13.73 ,
15
15
"minCoveredMsi": 100.00
16
16
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Setono \SyliusCatalogPromotionPlugin \Controller ;
6
+
7
+ use Setono \SyliusCatalogPromotionPlugin \Message \Command \StartCatalogPromotionUpdate ;
8
+ use Symfony \Component \HttpFoundation \RedirectResponse ;
9
+ use Symfony \Component \HttpFoundation \Request ;
10
+ use Symfony \Component \HttpFoundation \Session \Session ;
11
+ use Symfony \Component \Messenger \MessageBusInterface ;
12
+ use Symfony \Component \Routing \Generator \UrlGeneratorInterface ;
13
+
14
+ final class UpdateAllAction
15
+ {
16
+ public function __construct (
17
+ private readonly MessageBusInterface $ commandBus ,
18
+ private readonly UrlGeneratorInterface $ urlGenerator ,
19
+ ) {
20
+ }
21
+
22
+ public function __invoke (Request $ request ): RedirectResponse
23
+ {
24
+ $ this ->commandBus ->dispatch (new StartCatalogPromotionUpdate (triggeredBy: 'Clicking "Update all" button inside admin interface ' ));
25
+
26
+ $ session = $ request ->getSession ();
27
+ if ($ session instanceof Session) {
28
+ $ session ->getFlashBag ()->add ('success ' , 'setono_sylius_catalog_promotion.update_all_success ' );
29
+ }
30
+
31
+ return new RedirectResponse ($ this ->getUrl ($ request ));
32
+ }
33
+
34
+ private function getUrl (Request $ request ): string
35
+ {
36
+ $ referrer = $ request ->headers ->get ('referer ' );
37
+ if (null !== $ referrer && '' !== $ referrer ) {
38
+ return $ referrer ;
39
+ }
40
+
41
+ return $ this ->urlGenerator ->generate ('setono_sylius_catalog_promotion_admin_catalog_promotion_index ' );
42
+ }
43
+ }
Original file line number Diff line number Diff line change @@ -313,6 +313,16 @@ public function prepend(ContainerBuilder $container): void
313
313
],
314
314
],
315
315
],
316
+ 'update_all ' => [
317
+ 'type ' => 'default ' ,
318
+ 'label ' => 'setono_sylius_catalog_promotion.ui.update_all_catalog_promotions ' ,
319
+ 'icon ' => 'redo ' ,
320
+ 'options ' => [
321
+ 'link ' => [
322
+ 'route ' => 'setono_sylius_consent_management_admin_update_all_catalog ' ,
323
+ ],
324
+ ],
325
+ ],
316
326
'create ' => [
317
327
'type ' => 'create ' ,
318
328
],
Original file line number Diff line number Diff line change @@ -30,3 +30,9 @@ setono_sylius_catalog_promotion_admin_catalog_promotion:
30
30
templates:
31
31
form: "@SetonoSyliusCatalogPromotionPlugin/admin/catalog_promotion/_form.html.twig"
32
32
type : sylius.resource
33
+
34
+ setono_sylius_consent_management_admin_update_all_catalog :
35
+ path : /catalog-promotions/update-all
36
+ methods : GET
37
+ defaults :
38
+ _controller : Setono\SyliusCatalogPromotionPlugin\Controller\UpdateAllAction
Original file line number Diff line number Diff line change 8
8
<import resource =" services/checker.xml" />
9
9
<import resource =" services/command.xml" />
10
10
<import resource =" services/context.xml" />
11
+ <import resource =" services/controller.xml" />
11
12
<import resource =" services/data_provider.xml" />
12
13
<import resource =" services/event_subscriber.xml" />
13
14
<import resource =" services/factory.xml" />
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+
3
+ <container xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xmlns =" http://symfony.com/schema/dic/services"
5
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
6
+ <services >
7
+ <service id =" Setono\SyliusCatalogPromotionPlugin\Controller\UpdateAllAction" public =" true" >
8
+ <argument type =" service" id =" setono_sylius_catalog_promotion.command_bus" />
9
+ <argument type =" service" id =" router" />
10
+ </service >
11
+ </services >
12
+ </container >
Original file line number Diff line number Diff line change
1
+ setono_sylius_catalog_promotion :
2
+ update_all_success : An update of all catalog promotions was triggered.
Original file line number Diff line number Diff line change @@ -63,3 +63,4 @@ setono_sylius_catalog_promotion:
63
63
triggered_by : Triggered by
64
64
updated_at : Updated at
65
65
name_or_code : Name or code
66
+ update_all_catalog_promotions : Update all
You can’t perform that action at this time.
0 commit comments