Completed
Push — master ( 28dda4...aabe55 )
by Craig
06:13
created

FormAwareResponse   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 58
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getFormData() 0 8 2
A getFormSubject() 0 4 1
A getSubjectUrl() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Zikula package.
5
 *
6
 * Copyright Zikula Foundation - http://zikula.org/
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 Zikula\Bundle\HookBundle\FormAwareHook;
13
14
use Symfony\Component\Form\FormInterface;
15
use Zikula\Bundle\HookBundle\Hook\Hook;
16
use Zikula\Core\UrlInterface;
17
18
class FormAwareResponse extends Hook
19
{
20
    /**
21
     * @var FormInterface
22
     */
23
    private $form;
24
25
    /**
26
     * @var mixed
27
     */
28
    private $formSubject;
29
30
    /**
31
     * @var UrlInterface
32
     */
33
    private $subjectUrl;
34
35
    /**
36
     * @param FormInterface $form
37
     * @param mixed|null $formSubject This may be the object, an array, the subject id, null
38
     * @param null|UrlInterface $subjectUrl
39
     */
40
    public function __construct(FormInterface $form, $formSubject = null, UrlInterface $subjectUrl = null)
41
    {
42
        $this->form = $form;
43
        $this->formSubject = $formSubject;
44
        $this->subjectUrl = $subjectUrl;
45
    }
46
47
    /**
48
     * @param null $name
49
     * @return array
50
     */
51
    public function getFormData($name = null)
52
    {
53
        if (isset($name)) {
54
            return $this->form->get($name)->getData();
55
        }
56
57
        return $this->form->getData();
58
    }
59
60
    /**
61
     * @return mixed
62
     */
63
    public function getFormSubject()
64
    {
65
        return $this->formSubject;
66
    }
67
68
    /**
69
     * @return null|UrlInterface
70
     */
71
    public function getSubjectUrl()
72
    {
73
        return $this->subjectUrl;
74
    }
75
}
76