getField('id'); /** @var AbstractUser $currentUser */ $currentUser = $this->container->get('logged.in.user'); if (!$this->getContainer()->getPermissionsService()->currentUserCanRead(Entities::EMPLOYEES) || ( !$this->getContainer()->getPermissionsService()->currentUserCanReadOthers(Entities::EMPLOYEES) && $currentUser->getId()->getValue() !== $providerId ) ) { throw new AccessDeniedException('You are not allowed to read employee.'); } $result = new CommandResult(); /** @var ProviderApplicationService $providerService */ $providerService = $this->container->get('application.user.provider.service'); /** @var SettingsService $settingsService */ $settingsService = $this->container->get('domain.settings.service'); /** @var GoogleCalendarService $googleCalService */ $googleCalService = $this->container->get('infrastructure.google.calendar.service'); $companyDaysOff = $settingsService->getCategorySettings('daysOff'); $companyDayOff = $providerService->checkIfTodayIsCompanyDayOff($companyDaysOff); /** @var Provider $provider */ $provider = $providerService->getProviderWithServicesAndSchedule($providerId); if (!$provider instanceof AbstractUser) { $result->setResult(CommandResult::RESULT_ERROR); $result->setMessage('Could not retrieve user'); return $result; } $providerArray = $providerService->manageProvidersActivity( [$provider->toArray()], $companyDayOff )[0]; $successfulGoogleConnection = true; if ($googleCalService) { try { // Get Provider's Google Calendar List $providerArray['googleCalendar']['calendarList'] = $googleCalService->listCalendarList($provider); // Set Provider's Default Google Calendar Id $providerArray['googleCalendar']['calendarId'] = $googleCalService->getProviderGoogleCalendarId($provider); } catch (\Exception $e) { $successfulGoogleConnection = false; } } $result->setResult(CommandResult::RESULT_SUCCESS); $result->setMessage('Successfully retrieved user.'); $result->setData([ Entities::USER => $providerArray, 'successfulGoogleConnection' => $successfulGoogleConnection ]); return $result; } }