projectRepository = $projectRepository; $this->groupProvider = $groupProvider; $this->updateQuery = $updateQuery; } /** * @param int $projectId [description] * * @return ProjectReadView|bool [description] */ public function read(int $projectId) { $project = $this->projectRepository->findById($projectId); if (null === $project) { return false; } $projectDocuments = []; foreach ($project->getProjectDocuments() as $projectDocument) { $projectDocuments[] = new ProjectDocumentView( $projectDocument->getId(), $projectDocument->getFilename(), $projectDocument->getSize(), $projectDocument->getMimeType() ); } return new ProjectReadView( $project->getId(), $project->getName(), $project->getDescription() ?: '', $project->getDraft(), $project->getProductsImport(), $project->getIdUser(), $project->getIdOwnerGroup(), $projectDocuments, !empty($project->getFlux()) ? true : false ); } /** * @param int $projectId [description] * * @return string [description] */ public function lastStepConfigurationValid(int $projectId) { $project = $this->projectRepository->findById($projectId); if (null === $project) { return false; } if (is_int($project->getCurrentStep())) { $currentStepConfiguration = $project->getCurrentStep(); } else { $currentStepConfiguration = -1; } return $currentStepConfiguration; } /** * @param int $projectId [description] * * @return array [description] */ public function readGroup(int $projectId) { $project = $this->projectRepository->findById($projectId); if (!empty($project)) { $groupIds = []; $groups = []; foreach ($project->getGroupProject() as $groupProject) { $groupIds[] = $groupProject->getGroup(); } if (!empty($groupIds)) { $groups = $this->groupProvider->getByIds($groupIds)['data']; } return $groups; } return null; } }