Completed
Push — checkout-optimisation ( 4a6bfb...756f29 )
by Kamil
18:24
created

ResourceUpdateHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 11 2
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
namespace Sylius\Bundle\ResourceBundle\Controller;
13
14
use Doctrine\Common\Persistence\ObjectManager;
15
use Sylius\Component\Resource\Model\ResourceInterface;
16
17
/**
18
 * @author Grzegorz Sadowski <[email protected]>
19
 */
20
final class ResourceUpdateHandler implements ResourceUpdateHandlerInterface
21
{
22
    /**
23
     * @var StateMachineInterface
24
     */
25
    private $stateMachine;
26
27
    /**
28
     * @param StateMachineInterface $stateMachine
29
     */
30
    public function __construct(StateMachineInterface $stateMachine)
31
    {
32
        $this->stateMachine = $stateMachine;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function handle(
39
        ResourceInterface $resource,
40
        RequestConfiguration $configuration,
41
        ObjectManager $manager
42
    ) {
43
        if ($configuration->hasStateMachine()) {
44
            $this->stateMachine->apply($configuration, $resource);
45
        }
46
47
        $manager->flush();
48
    }
49
}
50