setName('workflows:runtime:list') ->setDescription('Lists configured runtime workflows') // need to add an optional filtering by app ->addArgument( 'appId', InputArgument::OPTIONAL, 'Filter runtime workflows by appId', null ) ->addArgument( 'scope', InputArgument::OPTIONAL, 'Lists workflows for "admin", "user"', 'admin' ) ->addArgument( 'userId', InputArgument::OPTIONAL, 'User ID used for user scope and session', null ); } protected function mappedScope(string $scope): int { return match($scope) { 'admin' => IManager::SCOPE_ADMIN, 'user' => IManager::SCOPE_USER, default => -1, }; } #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $appId = $input->getArgument('appId'); $userId = $input->getArgument('userId'); if ($userId !== null) { $user = $this->userManager->get($userId); if ($user === null) { throw new NoUserException("user $userId not found"); } $this->userSession->setUser($user); $this->manager->reloadRuntimeOperations(); } $opsByClass = $this->manager->getAllRuntimeOperations( new ScopeContext( $this->mappedScope($input->getArgument('scope')), $input->getArgument('userId') ), $appId, ); foreach ($opsByClass as &$operations) { foreach ($operations as &$operation) { $checks = $operation->checks; $appId = $operation->appId; $operation = $operation->toArray(); $operation['checks'] = $this->manager->getRuntimeChecks($checks, $appId); } unset($operation); } unset($operations); $this->writeArrayInOutputFormat($input, $output, $opsByClass); return 0; } }