Passed
Push — master ( 6daa1b...44aa55 )
by Przemysław eRIZ
04:09
created

ExportWishlistToPdfAction::handleCommand()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 9
rs 10
1
<?php
2
3
/*
4
 * This file was created by developers working at BitBag
5
 * Do you need more information about us and what we do? Visit our https://bitbag.io website!
6
 * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7
*/
8
9
declare(strict_types=1);
10
11
namespace BitBag\SyliusWishlistPlugin\Controller\Action;
12
13
use BitBag\SyliusWishlistPlugin\Command\Wishlist\ExportSelectedProductsFromWishlistToPdf;
14
use Symfony\Component\Form\FormInterface;
15
use Symfony\Component\Messenger\Exception\HandlerFailedException;
16
17
final class ExportWishlistToPdfAction extends BaseWishlistProductsAction
18
{
19
    protected function handleCommand(FormInterface $form): void
20
    {
21
        try {
22
            $command = new ExportSelectedProductsFromWishlistToPdf($form->get('items')->getData());
23
            $this->messageBus->dispatch($command);
24
        } catch (HandlerFailedException $ex) {
25
            $this->flashBag->add(
26
                'error',
27
                'Select at least one product'
28
            );
29
        }
30
    }
31
}
32