Completed
Push — master ( 744293...180002 )
by Paweł
28:19 queued 16:57
created

ResourceDeleteHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Sylius\Bundle\CoreBundle\Doctrine\ORM\Handler;
15
16
use Doctrine\ORM\ORMException;
17
use Sylius\Bundle\ResourceBundle\Controller\ResourceDeleteHandlerInterface;
18
use Sylius\Component\Resource\Exception\DeleteHandlingException;
19
use Sylius\Component\Resource\Model\ResourceInterface;
20
use Sylius\Component\Resource\Repository\RepositoryInterface;
21
22
final class ResourceDeleteHandler implements ResourceDeleteHandlerInterface
23
{
24
    /**
25
     * @var ResourceDeleteHandlerInterface
26
     */
27
    private $decoratedHandler;
28
29
    /**
30
     * @param ResourceDeleteHandlerInterface $decoratedHandler
31
     */
32
    public function __construct(ResourceDeleteHandlerInterface $decoratedHandler)
33
    {
34
        $this->decoratedHandler = $decoratedHandler;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     *
40
     * @throws DeleteHandlingException
41
     */
42
    public function handle(ResourceInterface $resource, RepositoryInterface $repository): void
43
    {
44
        try {
45
            $this->decoratedHandler->handle($resource, $repository);
46
        } catch (ORMException $exception) {
47
            throw new DeleteHandlingException();
48
        }
49
    }
50
}
51