|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: sjhc1170 |
|
5
|
|
|
* Date: 07/05/2018 |
|
6
|
|
|
* Time: 09:36 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Iriven\Plugins\Form\Core; |
|
10
|
|
|
|
|
11
|
|
|
use \Iriven\Plugins\Form\Core\Libs\Collection; |
|
|
|
|
|
|
12
|
|
|
use \Iriven\Plugins\Form\Core\Interfaces\FormElementInterface; |
|
|
|
|
|
|
13
|
|
|
use \Iriven\Plugins\Form\Core\Libs\AttributesBuilder; |
|
|
|
|
|
|
14
|
|
|
use \Iriven\Plugins\Form\Core\Libs\Traits\KeyNormalizer; |
|
|
|
|
|
|
15
|
|
|
use \Iriven\Plugins\Form\Core\Libs\LabelGenerator; |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
class FormElement implements FormElementInterface |
|
18
|
|
|
{ |
|
19
|
|
|
use KeyNormalizer; |
|
20
|
|
|
private $label; |
|
21
|
|
|
protected $attributes; |
|
22
|
|
|
private $Types; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* FormElement constructor. |
|
26
|
|
|
* @param LabelGenerator|string $label |
|
27
|
|
|
* @param AttributesBuilder|array $attributes |
|
28
|
|
|
*/ |
|
29
|
|
|
public function __construct($label, $attributes=[]) |
|
30
|
|
|
{ |
|
31
|
|
|
if(!$label instanceof LabelGenerator) |
|
32
|
|
|
$label = new LabelGenerator($label,[]); |
|
33
|
|
|
$this->label = $label; |
|
34
|
|
|
|
|
35
|
|
|
if(!$attributes instanceof AttributesBuilder) |
|
36
|
|
|
$attributes = new AttributesBuilder($attributes); |
|
37
|
|
|
$this->attributes = $attributes; |
|
38
|
|
|
|
|
39
|
|
|
if(!$this->attributes->has('name')) |
|
40
|
|
|
$this->attributes->set('name',$this->normalize($this->label->getItem())); |
|
41
|
|
|
|
|
42
|
|
|
if(!$this->attributes->has('type')) |
|
43
|
|
|
$this->attributes->set('type','text'); |
|
44
|
|
|
if (!$this->attributes->has('id')) |
|
45
|
|
|
$this->attributes->createElementID($this->attributes->get('name', $this->label->getItemID())); |
|
46
|
|
|
|
|
47
|
|
|
$this->attributes->set('autocomplete','off'); |
|
48
|
|
|
|
|
49
|
|
|
$this->Types = new Collection(array_flip([ |
|
50
|
|
|
'button', |
|
51
|
|
|
'checkbox', |
|
52
|
|
|
'color', |
|
53
|
|
|
'date', |
|
54
|
|
|
'datetime', |
|
55
|
|
|
'datetime-local', |
|
56
|
|
|
'email', |
|
57
|
|
|
'file', |
|
58
|
|
|
'hidden', |
|
59
|
|
|
'image', |
|
60
|
|
|
'month', |
|
61
|
|
|
'number', |
|
62
|
|
|
'password', |
|
63
|
|
|
'radio', |
|
64
|
|
|
'range', |
|
65
|
|
|
'reset', |
|
66
|
|
|
'search', |
|
67
|
|
|
'submit', |
|
68
|
|
|
'tel', |
|
69
|
|
|
'text', |
|
70
|
|
|
'time', |
|
71
|
|
|
'url', |
|
72
|
|
|
'week'])); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return LabelGenerator|string |
|
77
|
|
|
*/ |
|
78
|
|
|
public function Label() |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->label; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return Collection |
|
85
|
|
|
*/ |
|
86
|
|
|
protected function Types() |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->Types; |
|
89
|
|
|
} |
|
90
|
|
|
/** |
|
91
|
|
|
* @return AttributesBuilder |
|
92
|
|
|
*/ |
|
93
|
|
|
public function Attributes() |
|
94
|
|
|
{ |
|
95
|
|
|
return $this->attributes; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @return string |
|
100
|
|
|
*/ |
|
101
|
|
|
public function RenderHtml() |
|
102
|
|
|
{ |
|
103
|
|
|
$html = ''; |
|
104
|
|
|
if($this->Types->has($this->attributes->get('type'))) |
|
105
|
|
|
{ |
|
106
|
|
|
$this->label->Attribute()->set('fieldtype',$this->attributes->get('type')); |
|
107
|
|
|
$this->label->Attribute()->set('for',$this->attributes->get('id')); |
|
108
|
|
|
|
|
109
|
|
|
$html .= $this->Label()->RenderHtml(); |
|
110
|
|
|
$html .= '<input'; |
|
111
|
|
|
$html .= $this->attributes->RenderHtml(); |
|
112
|
|
|
$html .= ' >'; |
|
113
|
|
|
} |
|
114
|
|
|
return $html; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
} |
|
118
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths