/** * @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; }
/** * Install a module * * @param Module $module * @param boolean $recollect (optional) * * @return boolean */ public function install(Module $module, bool $recollect = true) : bool { if (!$module->canBeInstalled()) { return false; } $config = $this->getConfig(); $modules = $config->read('modules.installed', array()); $modules[] = $module->name(); $config->write('modules.installed', $modules); $this->getComposerCLI()->dumpAutoload(); $this->reloadClassLoader(); if (false !== ($installer = $module->installer())) { $this->getContainer()->make($installer)->install(); } if ($recollect) { $this->getCollector()->recollect(); } $this->emit('module.installed.' . $module->name()); return true; }