getContainer()->getPermissionsService()->currentUserCanRead(Entities::EMPLOYEES)) { throw new AccessDeniedException('You are not allowed to read employees.'); } if (!$this->getContainer()->getPermissionsService()->currentUserCanRead(Entities::CUSTOMERS)) { throw new AccessDeniedException('You are not allowed to read customers.'); } $result = new CommandResult(); $this->checkMandatoryFields($command); /** @var UserService $userService */ $userService = $this->container->get('users.service'); $adminIds = $userService->getWpUserIdsByRoles(['administrator']); /** @var WPUserRepository $wpUserRepository */ $wpUserRepository = $this->getContainer()->get('domain.wpUsers.repository'); $result->setResult(CommandResult::RESULT_SUCCESS); $result->setMessage('Successfully retrieved users.'); $result->setData([ Entities::USER . 's' => $wpUserRepository->getAllNonRelatedWPUsers($command->getFields(), $adminIds) ]); return $result; } }