Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final class GetPostSalesDocuments implements GetPostSalesDocumentsInterface
- {
- private $find_documents_provider;
- private $policy_repository;
- public function __construct(
- FindDocumentsProvider $find_documents_provider,
- PolicyRepositoryInterface $policy_repository
- ) {
- $this->find_documents_provider = $find_documents_provider;
- $this->policy_repository = $policy_repository;
- }
- public function getPostSalesDocuments(int $policy_id)
- {
- try {
- $this->getDocuments($this->getPolicyDirId($policy_id));
- } catch (\Exception $e) {
- }
- }
- private function getPolicyDirId(int $policy_id)
- {
- $policy = $this->policy_repository->findOneById($policy_id);
- if ($policy === null) {
- throw new Exception('Polisa ' . $policy_id . ' nie istnieje', 404);
- }
- if (empty($policy->getIntragrafDirId())) {
- throw new PolicyDirNotExistsException('Katalog dla polisy ' . $policy_id . ' nie istnieje', 500);
- }
- return $policy->getIntragrafDirId();
- }
- private function getDocuments(int $intragraf_dir_id): array
- {
- $documents = $this->find_documents_provider->getDocuments(
- [
- FindDocumentsEnum::ID_DOCUMENT_TYPE => $intragraf_dir_id,
- FindDocumentsEnum::TYP_DOC => WebstartEnum::SCAN_TYPE_SOLD,
- FindDocumentsEnum::TYP_DOC => WebstartEnum::SCAN_TYPE_DAMAGE,
- ]
- );
- if (empty($documents->getDocuments()) || $documents->getErrors()) {
- throw new FileNotFoundException('Brak zeskanowanych plików ', 404);
- }
- return $documents->getDocuments();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement