addArgument('handle', InputArgument::REQUIRED, 'Module handle to enable') ->setHelp('This command enables a previously disabled module.') ; } protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $handle = $input->getArgument('handle'); $io->title('Enable Module'); try { // Find the module $modules = $this->moduleManager->list(installedOnly: true, enabledOnly: false); $module = $modules[$handle] ?? null; if (!$module) { $io->error("Module '{$handle}' not found or not installed."); return Command::FAILURE; } if ($module->enabled()) { $io->warning("Module '{$handle}' is already enabled."); return Command::SUCCESS; } // Enable the module $io->text("Enabling module '{$handle}'..."); $this->moduleManager->enable($handle); $this->logger->info('Module enabled via console', [ 'handle' => $handle, 'command' => $this->getName(), ]); $io->success("Module '{$handle}' enabled successfully!"); return Command::SUCCESS; } catch (\Throwable $e) { $io->error('Failed to enable module: ' . $e->getMessage()); $this->logger->error('Module enable failed', [ 'handle' => $handle, 'error' => $e->getMessage(), ]); return Command::FAILURE; } } }