forked from Sylius/Sylius
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature Sylius#14291 [CatalogPromotions][UI] Removal of catalog promo…
…tions (Rafikooo) This PR was merged into the 1.12 branch. Discussion ---------- | Q | A | |-----------------|--------------------------------------------------------------| | Branch? | 1.12 <!-- see the comment below --> | | Bug fix? | no | | New feature? | yes | | BC breaks? | yes | | Deprecations? | no <!-- don't forget to update the UPGRADE-*.md file --> | | Related tickets | Sylius#14270 | License | MIT | <img width="1159" alt="image" src="https://user-images.githubusercontent.com/40125720/189155094-6d322ff0-d207-4193-9ff4-aa00af69e429.png"> Commits ------- 15f3696 [CatalogPromotions][Behat][UI] Removing catalog promotion scenarios implemented c95d73a [CatalogPromotions][UI] Removing catalog promotion
- Loading branch information
Showing
11 changed files
with
149 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/Sylius/Behat/Resources/config/suites/ui/promotion/removing_catalog_promotions.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This file is part of the Sylius package. | ||
# (c) Paweł Jędrzejewski | ||
|
||
default: | ||
suites: | ||
ui_removing_catalog_promotions: | ||
contexts: | ||
- sylius.behat.context.hook.doctrine_orm | ||
- Sylius\Calendar\Tests\Behat\Context\Hook\CalendarContext | ||
|
||
- sylius.behat.context.transform.channel | ||
- sylius.behat.context.transform.lexical | ||
- sylius.behat.context.transform.locale | ||
- sylius.behat.context.transform.product | ||
- sylius.behat.context.transform.product_variant | ||
- sylius.behat.context.transform.shared_storage | ||
- sylius.behat.context.transform.taxon | ||
- Sylius\Behat\Context\Transform\CatalogPromotionContext | ||
|
||
- sylius.behat.context.setup.admin_security | ||
- sylius.behat.context.setup.channel | ||
- sylius.behat.context.setup.product | ||
- sylius.behat.context.setup.product_taxon | ||
- sylius.behat.context.setup.taxonomy | ||
- Sylius\Behat\Context\Setup\CatalogPromotionContext | ||
- Sylius\Calendar\Tests\Behat\Context\Setup\CalendarContext | ||
|
||
- sylius.behat.context.ui.admin.notification | ||
- sylius.behat.context.ui.shop.product | ||
- Sylius\Behat\Context\Ui\Admin\ManagingCatalogPromotionsContext | ||
|
||
filters: | ||
tags: "@removing_catalog_promotions&&@ui" |
48 changes: 48 additions & 0 deletions
48
src/Sylius/Bundle/AdminBundle/Controller/RemoveCatalogPromotionAction.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Bundle\AdminBundle\Controller; | ||
|
||
use Sylius\Bundle\CoreBundle\CatalogPromotion\Processor\CatalogPromotionRemovalProcessorInterface; | ||
use Sylius\Component\Promotion\Exception\CatalogPromotionNotFoundException; | ||
use Sylius\Component\Promotion\Exception\InvalidCatalogPromotionStateException; | ||
use Symfony\Component\HttpFoundation\Exception\BadRequestException; | ||
use Symfony\Component\HttpFoundation\RedirectResponse; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpFoundation\Session\Session; | ||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||
|
||
final class RemoveCatalogPromotionAction | ||
{ | ||
public function __construct(private CatalogPromotionRemovalProcessorInterface $catalogPromotionRemovalProcessor) | ||
{ | ||
} | ||
|
||
public function __invoke(Request $request): Response | ||
{ | ||
try { | ||
$this->catalogPromotionRemovalProcessor->removeCatalogPromotion($request->attributes->get('code')); | ||
|
||
/** @var Session $session */ | ||
$session = $request->getSession(); | ||
$session->getFlashBag()->add('success', 'sylius.catalog_promotion.remove'); | ||
|
||
return new RedirectResponse($request->headers->get('referer')); | ||
} catch (CatalogPromotionNotFoundException) { | ||
throw new NotFoundHttpException('The catalog promotion has not been found'); | ||
} catch (InvalidCatalogPromotionStateException $exception) { | ||
throw new BadRequestException($exception->getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/Sylius/Bundle/AdminBundle/Resources/views/Grid/deleteCatalogPromotion.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{% set path = options.link.url|default(path(options.link.route, options.link.parameters)) %} | ||
|
||
<form action="{{ path }}" method="post"> | ||
<button | ||
{% if options.state == 'processing' %} disabled {% endif %} | ||
class="ui labeled {% if options.state != 'processing' %}red {% endif %}icon button" | ||
type="submit" | ||
data-requires-confirmation {{ sylius_test_html_attribute('delete-button') }} | ||
> | ||
<i class="icon {% if action.icon is not empty %} {{ action.icon }} {% else %}trash{% endif %}"></i> | ||
{% if action.label is not empty %} {{ action.label|trans }} {% else %} {{ 'sylius.ui.delete'|trans }} {% endif %} | ||
</button> | ||
<input type="hidden" name="_csrf_token" value="{{ csrf_token(options.link.parameters.code) }}" /> | ||
<input type="hidden" name="_method" value="DELETE"/> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters