@@ -63,12 +63,16 @@ protected function processClasses($classes)
63
63
*/
64
64
protected function getModifiers ()
65
65
{
66
- if (is_null ($ this ->modifiers )) {
66
+ if (! is_null ($ this ->attributes )) {
67
67
$ modifiers = $ this ->attributes ->get ('modifiers ' );
68
- $ this ->modifiers = $ this ->processModifiers ($ modifiers );
68
+
69
+ $ this ->modifiers = array_merge (
70
+ $ this ->processModifiers ($ modifiers ),
71
+ $ this ->modifiers ?? []
72
+ );
69
73
}
70
74
71
- return $ this ->modifiers ;
75
+ return $ this ->modifiers ?? [] ;
72
76
}
73
77
74
78
/**
@@ -104,4 +108,37 @@ public function hasClass($classname)
104
108
return in_array ($ classname , $ this ->getClasses ());
105
109
}
106
110
111
+ /**
112
+ * Set a modifier programmatically
113
+ *
114
+ * @param string $modifier
115
+ * @return void
116
+ */
117
+ public function modifier (string $ modifier )
118
+ {
119
+ if (is_null ($ this ->modifiers )) {
120
+ $ this ->modifiers = [];
121
+ }
122
+
123
+ $ this ->modifiers [] = $ modifier ;
124
+ }
125
+
126
+ /**
127
+ * Set multiple modifiers programmatically
128
+ *
129
+ * @param array $modifiers
130
+ * @param boolean $overwrite
131
+ * @return void
132
+ */
133
+ public function modifiers (array $ modifiers , $ overwrite = false )
134
+ {
135
+ if ($ overwrite ) {
136
+ $ this ->modifiers = $ modifiers ;
137
+
138
+ return ;
139
+ }
140
+
141
+ $ this ->modifiers = array_merge ($ this ->getModifiers (), $ modifiers );
142
+ }
143
+
107
144
}
0 commit comments