getContainer()->getPermissionsService()->currentUserCanRead(Entities::SERVICES)) { throw new AccessDeniedException('You are not allowed to read services.'); } $result = new CommandResult(); $this->checkMandatoryFields($command); /** @var ServiceRepository $serviceRepository */ $serviceRepository = $this->container->get('domain.bookable.service.repository'); $services = $serviceRepository->getAll(); if (!$services instanceof AbstractCollection) { $result->setResult(CommandResult::RESULT_ERROR); $result->setMessage('Could not get bookable services.'); return $result; } $result->setResult(CommandResult::RESULT_SUCCESS); $result->setMessage('Successfully retrieved services.'); $result->setData( [ Entities::SERVICES => $services->toArray() ] ); return $result; } }