Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
 /**
  * Uninstall a module
  *
  * @param   Module $module
  * @param   boolean $recollect (optional)
  *
  * @return  boolean
  */
 public function uninstall(Module $module, bool $recollect = true) : bool
 {
     if (!$module->canBeUninstalled()) {
         return false;
     }
     $config = $this->getConfig();
     $modules = $config->read('modules.installed', array());
     $config->write('modules.installed', array_diff($modules, array($module->name())));
     if (false !== ($installer = $module->installer())) {
         $this->getContainer()->make($installer)->uninstall();
     }
     $this->getComposerCLI()->dumpAutoload();
     $this->reloadClassLoader();
     if ($recollect) {
         $this->getCollector()->recollect();
     }
     $this->emit('module.uninstalled.' . $module->name());
     return true;
 }