Completed
Push — develop ( 515643...e2e58e )
by
unknown
08:08
created

GeoSelect::setHeadscripts()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 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
/** */
11
namespace Geo\Form;
12
13
use Core\Form\HeadscriptProviderInterface;
14
use Core\Form\Hydrator\HydratorStrategyProviderInterface;
15
use Core\Form\Hydrator\HydratorStrategyProviderTrait;
16
use Traversable;
17
use Zend\Form\Element\Select;
18
use Zend\Form\Element;
19
use Zend\Form\ElementInterface;
20
use Zend\Form\Exception\InvalidArgumentException;
21
22
/**
23
 * ${CARET}
24
 * 
25
 * @author Mathias Gelhausen <[email protected]>
26
 * @todo write test 
27
 */
28
class GeoSelect extends Select implements HeadscriptProviderInterface, HydratorStrategyProviderInterface
29
{
30
    use HydratorStrategyProviderTrait;
31
32
    /**
33
     * @var bool
34
     */
35
    protected $disableInArrayValidator = true;
36
37
    private $headscripts = [
38
        'Geo/js/geoselect.js'
39
    ];
40
41
    public function setOptions($options)
42
    {
43
        parent::setOptions($options);
44
45
        if (isset($options['location_entity'])) {
46
            $this->getHydratorStrategy()->setLocationEntityPrototype($options['location_entity']);
47
        }
48
    }
49
50
    public function setValue($value)
51
    {
52
        $this->setAttribute('data-val', $value);
53
54
        return parent::setValue($value); // TODO: Change the autogenerated stub
55
    }
56
57
58
    /**
59
     * Sets the array of script names.
60
     *
61
     * @param string[] $scripts
62
     *
63
     * @return self
64
     */
65
    public function setHeadscripts(array $scripts)
66
    {
67
        $this->headscripts = $scripts;
68
69
        return $this;
70
    }
71
72
    /**
73
     * Gets the array of script names.
74
     *
75
     * @return string[]
76
     */
77
    public function getHeadscripts()
78
    {
79
        return $this->headscripts;
80
    }
81
82
83
    public function init()
84
    {
85
        $this->setAttributes([
86
                'data-placeholder' => /*@translate*/ 'Location',
87
                'data-autoinit' => false,
88
                'class' => 'geoselect',
89
        ]);
90
91
    }
92
}