Completed
Push — develop ( 09456b...2094a2 )
by Mathias
14s queued 10s
created

OrganizationsProfileFieldset   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getHydrator() 0 8 2
A init() 0 16 1
A getInputFilterSpecification() 0 4 1
A allowObjectBinding() 0 4 1
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @license MIT
7
 * @copyright  2013 - 2017 Cross Solution <http://cross-solution.de>
8
 */
9
10
namespace Organizations\Form;
11
12
13
use Core\Entity\Hydrator\EntityHydrator;
14
use Organizations\Entity\Organization;
15
use Zend\Form\Fieldset;
16
17
/**
18
 * Class OrganizationsProfileFieldset
19
 *
20
 * @author  Anthonius Munthi <[email protected]>
21
 * @since   0.30
22
 * @package Organizations\Form
23
 */
24
class OrganizationsProfileFieldset extends Fieldset
25
{
26
    /**
27
     * Gets the Hydrator
28
     *
29
     * @return \Zend\Hydrator\HydratorInterface
30
     */
31
    public function getHydrator()
32
    {
33
        if (!$this->hydrator) {
34
            $hydrator           = new EntityHydrator();
35
            $this->setHydrator($hydrator);
36
        }
37
        return $this->hydrator;
38
    }
39
40
    public function init()
41
    {
42
        $this->setName('profile-setting');
43
        $this->add([
44
            'type' => 'select',
45
            'name' => 'profileSetting',
46
            'options' => [
47
                'label' => /*@translate*/ 'Setting',
48
                'value_options' => [
49
                    Organization::PROFILE_ALWAYS_ENABLE => /*@translate*/ 'Always enable profile',
50
                    Organization::PROFILE_ACTIVE_JOBS   => /*@translate*/ 'Enable only when active jobs available',
51
                    Organization::PROFILE_DISABLED      => /*@translate*/ 'Disabled viewing profile',
52
                ]
53
            ]
54
        ]);
55
    }
56
57
    /**
58
     * for later use - all the mandatory fields
59
     * @return array
60
     */
61
    public function getInputFilterSpecification()
62
    {
63
        return array();
64
    }
65
66
    /**
67
     * a required method to overwrite the generic method to make the binding of the entity work
68
     * @param object $object
69
     * @return bool
70
     */
71
    public function allowObjectBinding($object)
72
    {
73
        return $object instanceof Organization;
74
    }
75
76
}
77