1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: sjhc1170 |
5
|
|
|
* Date: 07/05/2018 |
6
|
|
|
* Time: 09:33 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Iriven\Plugins\Form\Core\Libs; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
use \Iriven\Plugins\Form\Core\Interfaces\LabelCreatorInterface; |
|
|
|
|
13
|
|
|
use \Iriven\Plugins\Form\Core\Libs\Traits\KeyNormalizer; |
|
|
|
|
14
|
|
|
|
15
|
|
|
class LabelGenerator implements LabelCreatorInterface |
16
|
|
|
{ |
17
|
|
|
use KeyNormalizer; |
18
|
|
|
private $item; |
19
|
|
|
private $attributes; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* LabelGenerator constructor. |
23
|
|
|
* |
24
|
|
|
* @param string $item |
25
|
|
|
* @param AttributesBuilder|array $attributes |
26
|
|
|
*/ |
27
|
|
|
public function __construct(string $item, $attributes=[]) |
28
|
|
|
{ |
29
|
|
|
$this->item = $item; |
30
|
|
|
if(!$attributes instanceof AttributesBuilder) |
31
|
|
|
$attributes = new AttributesBuilder($attributes); |
32
|
|
|
$this->attributes = $attributes; |
33
|
|
|
$this->attributes->set('type','label'); |
34
|
|
|
return $this; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @return AttributesBuilder |
39
|
|
|
*/ |
40
|
|
|
public function Attribute() |
41
|
|
|
{ |
42
|
|
|
return $this->attributes; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return bool|mixed|string |
47
|
|
|
*/ |
48
|
|
|
public function getItem() |
49
|
|
|
{ |
50
|
|
|
return $this->item; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @return mixed |
55
|
|
|
*/ |
56
|
|
|
public function getItemID() |
57
|
|
|
{ |
58
|
|
|
|
59
|
|
|
if(!$this->attributes->has('for')) |
60
|
|
|
{ |
61
|
|
|
$this->attributes->createElementID($this->item); |
62
|
|
|
$id = $this->attributes->get('id'); |
63
|
|
|
$this->attributes->set('for',$id); |
64
|
|
|
return $id; |
65
|
|
|
} |
66
|
|
|
return $this->attributes->get('for'); |
67
|
|
|
} |
68
|
|
|
/** |
69
|
|
|
* @return string |
70
|
|
|
*/ |
71
|
|
|
public function RenderHtml() |
72
|
|
|
{ |
73
|
|
|
$this->attributes->Ignore(['id','label','type']); |
74
|
|
|
$label = null; |
75
|
|
|
$type = $this->attributes->get('fieldtype'); |
76
|
|
|
$this->attributes->set('for',$this->attributes->get('for',$this->attributes->get('id'))); |
77
|
|
|
switch ($type): |
78
|
|
|
case 'hidden': |
79
|
|
|
case 'submit': |
80
|
|
|
case 'reset': |
81
|
|
|
case 'button': |
82
|
|
|
break; |
83
|
|
|
default: |
84
|
|
|
$label .= '<label'.$this->attributes->RenderHtml().'>'; |
85
|
|
|
$label .= htmlspecialchars(trim($this->item,': '),ENT_COMPAT,'UTF-8'); |
86
|
|
|
// $label .= $this->RenderErrors($label); |
87
|
|
|
$label .= ': </label>'; |
88
|
|
|
break; |
89
|
|
|
|
90
|
|
|
endswitch; |
91
|
|
|
return $label; |
92
|
|
|
} |
93
|
|
|
} |
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