Total Complexity | 4 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5 | trait BootstrapFormMessage |
||
6 | { |
||
7 | /** |
||
8 | * @var string[] |
||
9 | */ |
||
10 | protected static $bootstrapAlertsMap = [ |
||
11 | 'success' => 'alert-success', |
||
12 | 'good' => 'alert-success', |
||
13 | 'error' => 'alert-danger', |
||
14 | 'bad' => 'alert-danger', |
||
15 | 'required' => 'alert-danger', |
||
16 | 'warning' => 'alert-warning', |
||
17 | 'info' => 'alert-info', |
||
18 | ]; |
||
19 | |||
20 | /** |
||
21 | * Maps a SilverStripe message type to a Bootstrap alert type |
||
22 | */ |
||
23 | public function getAlertType() |
||
24 | { |
||
25 | $type = $this->owner->getMessageType(); |
||
26 | if (!$type) { |
||
27 | $type = 'info'; |
||
28 | } |
||
29 | if (isset(self::$bootstrapAlertsMap[$type])) { |
||
30 | return self::$bootstrapAlertsMap[$type]; |
||
31 | } |
||
32 | |||
33 | // Fallback to original |
||
34 | return $type; |
||
35 | } |
||
36 | |||
37 | public function BootstrapAlertType() |
||
40 | } |
||
41 | } |
||
42 |