Completed
Pull Request — master (#90)
by Arnaud
03:24
created

Action::getConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace LAG\AdminBundle\Action;
4
5
use LAG\AdminBundle\Action\Configuration\ActionConfiguration;
6
use LAG\AdminBundle\Action\Responder\CreateResponder;
7
use LAG\AdminBundle\Action\Responder\DeleteResponder;
8
use LAG\AdminBundle\Action\Responder\EditResponder;
9
use LAG\AdminBundle\Action\Responder\ResponderInterface;
10
use LAG\AdminBundle\Admin\Admin;
11
use LAG\AdminBundle\Admin\Behaviors\AdminAwareTrait;
12
use Symfony\Component\Form\FormFactoryInterface;
13
14
abstract class Action implements ActionInterface
15
{
16
    use AdminAwareTrait;
17
    
18
    /**
19
     * Action name.
20
     *
21
     * @var string
22
     */
23
    protected $name;
24
    
25
    /**
26
     * Action configuration (it has been resolved so it should be valid).
27
     *
28
     * @var ActionConfiguration
29
     */
30
    protected $configuration;
31
    
32
    /**
33
     * Form factory.
34
     *
35
     * @var FormFactoryInterface
36
     */
37
    protected $formFactory;
38
    
39
    
40
    /**
41
     * @var ResponderInterface|CreateResponder|DeleteResponder|EditResponder
42
     */
43
    protected $responder;
44
    
45
    /**
46
     * Action constructor.
47
     *
48
     * @param string               $name
49
     * @param FormFactoryInterface $formFactory
50
     * @param ResponderInterface   $responder
51
     */
52 4
    public function __construct(
53
        $name,
54
        FormFactoryInterface $formFactory,
55
        ResponderInterface $responder
56
    ) {
57 4
        $this->name = $name;
58 4
        $this->formFactory = $formFactory;
59 4
        $this->responder = $responder;
60 4
    }
61
    
62
    /**
63
     * @inheritdoc
64
     *
65
     * @param ActionConfiguration $configuration
66
     */
67 4
    public function setConfiguration(ActionConfiguration $configuration)
68
    {
69 4
        $this->configuration = $configuration;
70 4
    }
71
    
72
    /**
73
     * @inheritdoc
74
     *
75
     * @return ActionConfiguration
76
     */
77
    public function getConfiguration()
78
    {
79
        return $this->configuration;
80
    }
81
    
82
    /**
83
     * @inheritdoc
84
     *
85
     * @return bool
86
     */
87
    public function isLoadingRequired()
88
    {
89
        return Admin::LOAD_STRATEGY_NONE !== $this
90
            ->configuration
91
            ->getParameter('load_method')
92
        ;
93
    }
94
    
95
    /**
96
     * @inheritdoc
97
     *
98
     * @return string
99
     */
100
    public function getName()
101
    {
102
        return $this->name;
103
    }
104
}
105