-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OP-319 - Select parcel template fixes
- Loading branch information
Showing
5 changed files
with
28 additions
and
11 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
25 changes: 22 additions & 3 deletions
25
src/EventListener/SelectParcelTemplateEventListener/SelectParcelTemplateAction.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 |
---|---|---|
@@ -1,28 +1,47 @@ | ||
<?php | ||
|
||
/* | ||
* This file has been created by developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
* You can find more information about us on https://bitbag.io and write us | ||
* an email on [email protected]. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusInPostPlugin\EventListener\SelectParcelTemplateEventListener; | ||
|
||
use BitBag\SyliusInPostPlugin\Entity\ShippingExportInterface; | ||
use BitBag\SyliusShippingExportPlugin\Repository\ShippingExportRepositoryInterface; | ||
use Symfony\Component\HttpFoundation\RequestStack; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
||
class SelectParcelTemplateAction implements SelectParcelTemplateActionInterface | ||
{ | ||
private const INFO = 'info'; | ||
|
||
private const TRANSLATION_KEY = 'bitbag_sylius_inpost_plugin.ui.parcel_template.select_action_performed'; | ||
|
||
private ShippingExportRepositoryInterface $shippingExportRepository; | ||
|
||
private RequestStack $requestStack; | ||
|
||
public function __construct(ShippingExportRepositoryInterface $shippingExportRepository, RequestStack $requestStack) | ||
{ | ||
private TranslatorInterface $translator; | ||
|
||
public function __construct( | ||
ShippingExportRepositoryInterface $shippingExportRepository, | ||
RequestStack $requestStack, | ||
TranslatorInterface $translator, | ||
) { | ||
$this->shippingExportRepository = $shippingExportRepository; | ||
$this->requestStack = $requestStack; | ||
$this->translator = $translator; | ||
} | ||
|
||
public function execute(ShippingExportInterface $shippingExport): void | ||
{ | ||
$message = $this->translator->trans(self::TRANSLATION_KEY); | ||
$this->shippingExportRepository->add($shippingExport); | ||
$this->requestStack->getSession()->getBag('flashes')->add(self::INFO, self::TRANSLATION_KEY); | ||
$this->requestStack->getSession()->getBag('flashes')->add(self::INFO, $message); | ||
} | ||
} |
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