Completed
Pull Request — develop (#323)
by Mathias
15:36
created

ManagementFieldset::getHydrator()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @license MIT
7
 * @copyright  2013 - 2016 Cross Solution <http://cross-solution.de>
8
 */
9
  
10
/** */
11
namespace Core\Form\Tree;
12
13
use Core\Form\Element\ViewHelperProviderInterface;
14
use Core\Form\Hydrator\TreeHydrator;
15
use Core\Form\ViewPartialProviderInterface;
16
use Core\Form\ViewPartialProviderTrait;
17
use Zend\Form\Exception;
18
use Zend\Form\Fieldset;
19
use Zend\Form\FieldsetInterface;
20
use Zend\Hydrator;
21
use Zend\Hydrator\HydratorAwareInterface;
22
use Zend\Hydrator\HydratorInterface;
23
24
/**
25
 * Fieldset for managing tree items.
26
 * 
27
 * @author Mathias Gelhausen <[email protected]>
28
 * @since 0.29
29
 */
30
class ManagementFieldset extends Fieldset implements ViewPartialProviderInterface
31
{
32
33
    use ViewPartialProviderTrait;
34
35
    /**
36
     * Default view partial name.
37
     *
38
     * @var string
39
     */
40
    private $defaultPartial = 'core/form/tree-manage';
0 ignored issues
show
Unused Code introduced by
The property $defaultPartial is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
41
42
    public function getHydrator()
43
    {
44
        if (!$this->hydrator) {
45
            $this->setHydrator(new TreeHydrator());
46
        }
47
48
        return $this->hydrator;
49
    }
50
51
    public function init()
52
    {
53
        $this->add([
54
                'type' => 'Collection',
55
                'name' => 'items',
56
                'options' => [
57
                    'count' => 0,
58
                    'should_create_template' => true,
59
                    'allow_add' => true,
60
                    'target_element' => [
61
                        'type' => 'Core/Tree/AddItemFieldset',
62
                    ],
63
                ],
64
            ]);
65
    }
66
}