Example #1
0
 /**
  * Get & scan all modules.
  *
  * @return array
  */
 public function scan()
 {
     $path = $this->getScanPath();
     $modules = [];
     $manifests = File::glob("{$path}/zedx.json");
     is_array($manifests) || ($manifests = []);
     foreach ($manifests as $manifest) {
         $name = Json::make($manifest)->get('name');
         $lowerName = strtolower($name);
         $modules[$name] = new Module($lowerName, dirname($manifest));
     }
     return $modules;
 }
Example #2
0
 /**
  * Get & scan all widgets.
  *
  * @return array
  */
 protected function scan($group = null, $withoutSymlink = false)
 {
     $path = $this->getScanPath();
     $widgets = [];
     $manifests = File::glob("{$path}/zedx.json");
     is_array($manifests) || ($manifests = []);
     foreach ($manifests as $manifest) {
         if ($withoutSymlink && is_link(dirname(dirname($manifest)))) {
             continue;
         }
         $json = Json::make($manifest);
         $groups = $json->get('groups');
         if (!$this->allowedGroup($groups, $group)) {
             continue;
         }
         $studlyType = studly_case($json->get('type'));
         $studlyAuthor = studly_case($json->get('author'));
         $studlyName = studly_case($json->get('name'));
         $namespace = config('widgets.namespace');
         $fullName = "{$studlyType}\\{$studlyAuthor}\\{$studlyName}";
         $widget = "{$namespace}\\{$fullName}\\Widget";
         $widgetClass = new $widget($studlyType, $studlyAuthor, $studlyName, []);
         if (!$this->filter) {
             $widgets[$fullName] = $widgetClass;
             continue;
         }
         if ($this->filter == 'authors') {
             if (!isset($widgets[$studlyAuthor])) {
                 $widgets[$studlyAuthor][] = $widgetClass;
             } else {
                 array_push($widgets[$studlyAuthor], $widgetClass);
             }
         }
     }
     return $widgets;
 }