1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LeKoala\Admini\Forms; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Forms\LiteralField; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Bootstrap alert |
9
|
|
|
* Maps good/bad classes |
10
|
|
|
*/ |
11
|
|
|
class BootstrapAlertField extends LiteralField |
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var bool |
16
|
|
|
*/ |
17
|
|
|
protected $allowHTML = true; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
protected $alertType = 'info'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var bool |
26
|
|
|
*/ |
27
|
|
|
protected $messageClass = null; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param string $name |
31
|
|
|
* @param string|FormField $content |
|
|
|
|
32
|
|
|
* @param string $type |
33
|
|
|
*/ |
34
|
|
|
public function __construct($name, $content = null, $type = null) |
35
|
|
|
{ |
36
|
|
|
$this->setContent($content); |
37
|
|
|
|
38
|
|
|
parent::__construct($name, $content); |
39
|
|
|
|
40
|
|
|
if ($type) { |
41
|
|
|
$this->setAlertType($type); |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param array $properties |
47
|
|
|
* |
48
|
|
|
* @return string |
49
|
|
|
*/ |
50
|
|
|
public function FieldHolder($properties = array()) |
51
|
|
|
{ |
52
|
|
|
$content = parent::FieldHolder($properties); |
53
|
|
|
$type = $this->alertType; |
54
|
|
|
|
55
|
|
|
// Wrap in an alert |
56
|
|
|
$extraClasses = $this->extraClasses; |
57
|
|
|
if (is_array($extraClasses)) { |
|
|
|
|
58
|
|
|
$extraClasses = implode(" ", $extraClasses); |
59
|
|
|
} |
60
|
|
|
if ($extraClasses) { |
61
|
|
|
$extraClasses = " " . $extraClasses; |
62
|
|
|
} |
63
|
|
|
$classes = 'alert alert-' . $type . '' . $extraClasses; |
64
|
|
|
if ($this->messageClass) { |
65
|
|
|
$classes .= " message " . $this->messageClass; |
|
|
|
|
66
|
|
|
} |
67
|
|
|
$content = "<div class=\"{$classes}\" role=\"alert\">$content</div>"; |
68
|
|
|
|
69
|
|
|
return $content; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Get the value of alertType |
74
|
|
|
*/ |
75
|
|
|
public function getAlertType() |
76
|
|
|
{ |
77
|
|
|
return $this->alertType; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Set the value of alertType |
82
|
|
|
* |
83
|
|
|
* @return $this |
84
|
|
|
*/ |
85
|
|
|
public function setAlertType($alertType) |
86
|
|
|
{ |
87
|
|
|
switch ($alertType) { |
88
|
|
|
case 'bad': |
89
|
|
|
$this->messageClass = $alertType; |
90
|
|
|
$alertType = "danger"; |
91
|
|
|
break; |
92
|
|
|
case 'good': |
93
|
|
|
$this->messageClass = $alertType; |
94
|
|
|
$alertType = "success"; |
95
|
|
|
break; |
96
|
|
|
} |
97
|
|
|
$this->alertType = $alertType; |
98
|
|
|
|
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
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