Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. final class GetPostSalesDocuments implements GetPostSalesDocumentsInterface
  2. {
  3. private $find_documents_provider;
  4. private $policy_repository;
  5.  
  6. public function __construct(
  7. FindDocumentsProvider $find_documents_provider,
  8. PolicyRepositoryInterface $policy_repository
  9. ) {
  10. $this->find_documents_provider = $find_documents_provider;
  11. $this->policy_repository = $policy_repository;
  12. }
  13.  
  14. public function getPostSalesDocuments(int $policy_id)
  15. {
  16. try {
  17. $this->getDocuments($this->getPolicyDirId($policy_id));
  18. } catch (\Exception $e) {
  19. }
  20. }
  21.  
  22. private function getPolicyDirId(int $policy_id)
  23. {
  24. $policy = $this->policy_repository->findOneById($policy_id);
  25.  
  26. if ($policy === null) {
  27. throw new Exception('Polisa ' . $policy_id . ' nie istnieje', 404);
  28. }
  29.  
  30. if (empty($policy->getIntragrafDirId())) {
  31. throw new PolicyDirNotExistsException('Katalog dla polisy ' . $policy_id . ' nie istnieje', 500);
  32. }
  33.  
  34. return $policy->getIntragrafDirId();
  35. }
  36.  
  37. private function getDocuments(int $intragraf_dir_id): array
  38. {
  39. $documents = $this->find_documents_provider->getDocuments(
  40. [
  41. FindDocumentsEnum::ID_DOCUMENT_TYPE => $intragraf_dir_id,
  42. FindDocumentsEnum::TYP_DOC => WebstartEnum::SCAN_TYPE_SOLD,
  43. FindDocumentsEnum::TYP_DOC => WebstartEnum::SCAN_TYPE_DAMAGE,
  44. ]
  45. );
  46.  
  47. if (empty($documents->getDocuments()) || $documents->getErrors()) {
  48. throw new FileNotFoundException('Brak zeskanowanych plików ', 404);
  49. }
  50.  
  51. return $documents->getDocuments();
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement