Completed
Push — master ( fd10c7...b50c82 )
by Craig
06:29
created

UserFormDataEvent::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
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\UsersModule\Event;
13
14
use Symfony\Component\EventDispatcher\Event;
15
use Symfony\Component\Form\FormInterface;
16
use Zikula\UsersModule\Entity\UserEntity;
17
18
class UserFormDataEvent extends Event
19
{
20
    /**
21
     * @var FormInterface
22
     */
23
    private $form;
24
25
    /**
26
     * @var UserEntity
27
     */
28
    private $userEntity;
29
30
    /**
31
     * @param UserEntity $userEntity
32
     * @param FormInterface $form
33
     */
34
    public function __construct(UserEntity $userEntity, FormInterface $form)
35
    {
36
        $this->userEntity = $userEntity;
37
        $this->form = $form;
38
    }
39
40
    /**
41
     * @param null $prefix
42
     * @return array
43
     */
44
    public function getFormData($prefix = null)
45
    {
46
        if (isset($prefix)) {
47
            return $this->form->get($prefix)->getData();
48
        }
49
50
        return $this->form->getData();
51
    }
52
53
    /**
54
     * @return UserEntity
55
     */
56
    public function getUserEntity()
57
    {
58
        return $this->userEntity;
59
    }
60
}
61