@@ -63,12 +63,16 @@ protected function processClasses($classes)
6363 */
6464 protected function getModifiers ()
6565 {
66- if (is_null ($ this ->modifiers )) {
66+ if (! is_null ($ this ->attributes )) {
6767 $ 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+ );
6973 }
7074
71- return $ this ->modifiers ;
75+ return $ this ->modifiers ?? [] ;
7276 }
7377
7478 /**
@@ -104,4 +108,37 @@ public function hasClass($classname)
104108 return in_array ($ classname , $ this ->getClasses ());
105109 }
106110
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+
107144}
0 commit comments