addArgument('module', InputArgument::REQUIRED, 'O nome do módulo'); } protected function execute(InputInterface $input, OutputInterface $output): int { $module = strtolower($input->getArgument('module')); $modulePath = dirname(__DIR__, 3) . "/modules/{$module}"; if (!is_dir($modulePath)) { $output->writeln("Módulo '{$module}' não encontrado."); return Command::FAILURE; } $assetsPath = "{$modulePath}/assets"; if (!is_dir($assetsPath)) { $output->writeln("Nenhum diretório 'assets' encontrado no módulo '{$module}'."); return Command::SUCCESS; } $publicPath = dirname(__DIR__, 3) . "/public/assets/modules/{$module}"; if (!is_dir($publicPath)) { mkdir($publicPath, 0755, true); } $output->writeln("Copiando assets de '{$module}' para 'public/assets/modules/{$module}'..."); $this->copyDirectory($assetsPath, $publicPath); $output->writeln("Assets publicados com sucesso!"); return Command::SUCCESS; } protected function copyDirectory($source, $destination) { $dir = opendir($source); @mkdir($destination); while (false !== ($file = readdir($dir))) { if (($file != '.') && ($file != '..')) { if (is_dir($source . '/' . $file)) { $this->copyDirectory($source . '/' . $file, $destination . '/' . $file); } else { copy($source . '/' . $file, $destination . '/' . $file); } } } closedir($dir); } }