Beispiel #1
0
 /**
  * @return array
  */
 protected function resolveButtons() : array
 {
     $buttons = [];
     if ($this->module->name() === 'opis-colibri/manager') {
         $buttons[] = ['title' => 'Disable', 'value' => 'disable', 'form' => $this->form, 'disabled' => 'disabled="disabled"'];
     } elseif ($this->module->isEnabled()) {
         $buttons[] = ['title' => 'Disable', 'value' => 'disable', 'form' => $this->form, 'disabled' => $this->module->canBeDisabled() ? '' : 'disabled="disabled"'];
     } elseif ($this->module->isInstalled()) {
         $buttons[] = ['title' => 'Enable', 'value' => 'enable', 'form' => $this->form, 'disabled' => $this->module->canBeEnabled() ? '' : 'disabled="disabled"'];
         $buttons[] = ['title' => 'Uninstall', 'value' => 'uninstall', 'form' => $this->form, 'disabled' => $this->module->canBeUninstalled() ? '' : 'disabled="disabled"'];
     } else {
         $buttons[] = ['title' => 'Install', 'value' => 'install', 'form' => $this->form, 'disabled' => $this->module->canBeInstalled() ? '' : 'disabled="disabled"'];
     }
     return $buttons;
 }
Beispiel #2
0
 /**
  * Disable a module
  *
  * @param   Module $module
  * @param   boolean $recollect (optional)
  *
  * @return  boolean
  */
 public function disable(Module $module, bool $recollect = true) : bool
 {
     if (!$module->canBeDisabled()) {
         return false;
     }
     $config = $this->getConfig();
     $modules = $config->read('modules.enabled', array());
     $config->write('modules.enabled', array_diff($modules, array($module->name())));
     if (false !== ($installer = $module->installer())) {
         $this->getContainer()->make($installer)->disable();
     }
     $this->getComposerCLI()->dumpAutoload();
     $this->reloadClassLoader();
     if ($recollect) {
         $this->getCollector()->recollect();
     }
     $this->emit('module.disabled.' . $module->name());
     return true;
 }