|
16 | 16 | use \PatternLab\Console;
|
17 | 17 | use \PatternLab\Dispatcher;
|
18 | 18 | use \PatternLab\Timer;
|
| 19 | +use \Shudrum\Component\ArrayFinder\ArrayFinder; |
19 | 20 | use \Symfony\Component\Finder\Finder;
|
20 | 21 | use \Symfony\Component\Yaml\Exception\ParseException;
|
21 | 22 | use \Symfony\Component\Yaml\Yaml;
|
@@ -198,6 +199,8 @@ public static function get() {
|
198 | 199 | return self::$store;
|
199 | 200 | }
|
200 | 201 |
|
| 202 | + |
| 203 | + |
201 | 204 | /**
|
202 | 205 | * Generate the listItems array
|
203 | 206 | * @param {String} the filename for the pattern to be parsed
|
@@ -274,20 +277,19 @@ public static function getListItems($filepath,$ext = "json") {
|
274 | 277 | return $listItems;
|
275 | 278 |
|
276 | 279 | }
|
277 |
| - |
| 280 | + |
278 | 281 | /**
|
279 |
| - * Return the value for an option |
| 282 | + * Get an option for the data store |
| 283 | + * @param {String} a string in dot notation dictating where the option is in the data structure |
280 | 284 | *
|
281 |
| - * @return {String} the value of the option requested |
| 285 | + * @return {Array} the store |
282 | 286 | */
|
283 |
| - public static function getOption($optionName) { |
284 |
| - |
285 |
| - if (isset(self::$store[$optionName])) { |
286 |
| - return self::$store[$optionName]; |
| 287 | + public static function getOption($key = "") { |
| 288 | + if (!empty($key)) { |
| 289 | + $arrayFinder = new ArrayFinder(self::$store); |
| 290 | + return $arrayFinder->get($key); |
287 | 291 | }
|
288 |
| - |
289 | 292 | return false;
|
290 |
| - |
291 | 293 | }
|
292 | 294 |
|
293 | 295 | /**
|
@@ -359,7 +361,34 @@ public static function initPattern($optionName) {
|
359 | 361 | public static function printData() {
|
360 | 362 | print_r(self::$store);
|
361 | 363 | }
|
362 |
| - |
| 364 | + |
| 365 | + /** |
| 366 | + * Replace the data store |
| 367 | + * @param {Array} the new store |
| 368 | + */ |
| 369 | + public static function replaceStore($store) { |
| 370 | + self::$store = $store; |
| 371 | + } |
| 372 | + |
| 373 | + /** |
| 374 | + * Set an option for the data store |
| 375 | + * @param {String} a string in dot notation dictating where the option is in the data structure |
| 376 | + * @param {Mixed} the value for the key |
| 377 | + * |
| 378 | + * @return {Array} the store |
| 379 | + */ |
| 380 | + public static function setOption($key = "", $value = "") { |
| 381 | + |
| 382 | + if (empty($key)) { |
| 383 | + return false; |
| 384 | + } |
| 385 | + |
| 386 | + $arrayFinder = new ArrayFinder(self::$store); |
| 387 | + $arrayFinder->set($key, $value); |
| 388 | + self::$store = $arrayFinder->get(); |
| 389 | + |
| 390 | + } |
| 391 | + |
363 | 392 | /**
|
364 | 393 | * Set an option on a sub element of the data array
|
365 | 394 | * @param {String} name of the option
|
|
0 commit comments