getContainer()->getPermissionsService()->currentUserCanRead(Entities::EMPLOYEES)) { throw new AccessDeniedException('You are not allowed to read employees.'); } $result = new CommandResult(); /** @var ProviderRepository $providerRepository */ $providerRepository = $this->container->get('domain.users.providers.repository'); /** @var ProviderApplicationService $providerService */ $providerService = $this->container->get('application.user.provider.service'); /** @var SettingsService $settingsService */ $settingsService = $this->container->get('domain.settings.service'); $itemsPerPage = $settingsService->getSetting('general', 'itemsPerPage'); $companyDaysOff = $settingsService->getCategorySettings('daysOff'); $params = $command->getField('params'); if (!$this->getContainer()->getPermissionsService()->currentUserCanReadOthers(Entities::EMPLOYEES)) { /** @var AbstractUser $currentUser */ $currentUser = $this->container->get('logged.in.user'); $params['providers'][] = $currentUser->getId()->getValue(); } $providers = $providerRepository->getFiltered($params, $itemsPerPage); if (!$providers instanceof AbstractCollection) { $result->setResult(CommandResult::RESULT_ERROR); $result->setMessage('Could not get users'); return $result; } $result->setResult(CommandResult::RESULT_SUCCESS); $result->setMessage('Successfully retrieved users.'); $providers = $providers->toArray(); $companyDayOff = $providerService->checkIfTodayIsCompanyDayOff($companyDaysOff); $providers = $providerService->manageProvidersActivity($providers, $companyDayOff); $result->setData([ Entities::USERS => $providers, 'countFiltered' => (int)$providerRepository->getCount($command->getField('params')), 'countTotal' => (int)$providerRepository->getCount([]), ]); return $result; } }