Exemplo n.º 1
0
 /**
  * @param ModuleDefinition $model
  */
 public function addItems($model)
 {
     foreach ($model->menu as $name => $item) {
         if (isset($item['parent'])) {
             $this->addItemChild($name, $item['parent'], $model->createMenuItem($item));
         } else {
             $this->addItem($name, $model->createMenuItem($item));
         }
     }
 }
Exemplo n.º 2
0
 /**
  * @param array $config a definition file inside module folder
  * @throws InvalidConfigException
  */
 public function registerModule($config)
 {
     // Check mandatory config options
     if (!isset($config['class']) || !isset($config['id'])) {
         throw new InvalidConfigException("Module configuration requires an 'id' and 'class' attribute!");
     }
     $id = $config['id'];
     if (isset($this->modules[$id])) {
         return;
     }
     $definition = new ModuleDefinition($config);
     if ($definition->required) {
         $this->enabledModules[] = $id;
     }
     // Not enabled and not core module
     if (!$definition->isCore() && !in_array($id, $this->enabledModules)) {
         return;
     }
     if ($definition->isCore()) {
         $this->coreModules[$id] = $definition;
     }
     $definition->register();
     $this->modules[$id] = $definition;
 }