addOption('seed', null, InputOption::VALUE_NONE, 'Also (re)grant the built-in roles their default permissions'); $this->addOption('prune', null, InputOption::VALUE_NONE, 'Remove permissions that are no longer declared in code'); } protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); // Re-glob providers from disk first — the discovered-provider list is cached // cross-request outside debug mode, so a stale cache (e.g. predating a newly-shipped // domain's permission class) would otherwise hide its permissions from the sync. This // also makes the command a reliable recovery step after such a cache goes stale. $this->registry->flush(); $keys = $this->seeder->syncDiscoveredPermissions(); $io->success(count($keys).' permissions synced.'); if ($input->getOption('prune')) { $pruned = $this->repo->pruneOrphanPermissions($keys); $io->info($pruned.' orphaned permission(s) pruned.'); } if ($input->getOption('seed')) { $this->seeder->seedBuiltInRoles(); $io->info('Built-in role defaults seeded.'); } $this->permissions->flushCache(); return Command::SUCCESS; } }