Example #1
0
 /**
  * Return filtered list of widgets
  *
  * @param array $filters Key-value array of filters for widget node properties
  * @return array
  * @api
  */
 public function getWidgets($filters = [])
 {
     $widgets = $this->dataStorage->get();
     $result = $widgets;
     // filter widgets by params
     if (is_array($filters) && count($filters) > 0) {
         foreach ($widgets as $code => $widget) {
             try {
                 foreach ($filters as $field => $value) {
                     if (!isset($widget[$field]) || (string) $widget[$field] != $value) {
                         throw new \Exception();
                     }
                 }
             } catch (\Exception $e) {
                 unset($result[$code]);
                 continue;
             }
         }
     }
     return $result;
 }
Example #2
0
 public function testGet()
 {
     $result = $this->_configData->get();
     $expected = (include '_files/expectedGlobalDesignArray.php');
     $this->assertEquals($expected, $result);
 }