@@ -12,40 +12,40 @@ discard block |
||
| 12 | 12 | class TaskInterationService |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - public function __construct( |
|
| 15 | + public function __construct( |
|
| 16 | 16 | private EntityManagerInterface $manager, |
| 17 | 17 | private Security $security, |
| 18 | 18 | private StatusService $statusService, |
| 19 | 19 | private PeopleService $peopleService, |
| 20 | 20 | private FileService $fileService |
| 21 | - ) {} |
|
| 21 | + ) {} |
|
| 22 | 22 | |
| 23 | - public function addClientInteration(MessageInterface $message, People $provider, string $type): TaskInteration |
|
| 24 | - { |
|
| 23 | + public function addClientInteration(MessageInterface $message, People $provider, string $type): TaskInteration |
|
| 24 | + { |
|
| 25 | 25 | |
| 26 | 26 | $number = preg_replace('/\D/', '', $message->getOriginNumber()); |
| 27 | 27 | $name = ''; |
| 28 | 28 | $phone = [ |
| 29 | - 'ddi' => substr($number, 0, 2), |
|
| 30 | - 'ddd' => substr($number, 2, 2), |
|
| 31 | - 'phone' => substr($number, 4) |
|
| 29 | + 'ddi' => substr($number, 0, 2), |
|
| 30 | + 'ddd' => substr($number, 2, 2), |
|
| 31 | + 'phone' => substr($number, 4) |
|
| 32 | 32 | ]; |
| 33 | 33 | $registredBy = $this->peopleService->discoveryPeople(null, null, $phone, $name, null); |
| 34 | 34 | $task = $this->discoveryOpenTask($provider, $registredBy, $type); |
| 35 | 35 | return $this->addInteration($registredBy, $message, $task, $type, 'public'); |
| 36 | - } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - public function addInteration(People $registredBy, MessageInterface $message, Task $task, string $type, ?string $visibility = 'private') |
|
| 39 | - { |
|
| 38 | + public function addInteration(People $registredBy, MessageInterface $message, Task $task, string $type, ?string $visibility = 'private') |
|
| 39 | + { |
|
| 40 | 40 | |
| 41 | 41 | $file = null; |
| 42 | 42 | $media = $message->getMessageContent()->getMedia(); |
| 43 | 43 | if ($media) |
| 44 | - $file = $this->fileService->addFile( |
|
| 44 | + $file = $this->fileService->addFile( |
|
| 45 | 45 | $registredBy, |
| 46 | 46 | pack("C*", ...$media->getData()), |
| 47 | 47 | $type |
| 48 | - ); |
|
| 48 | + ); |
|
| 49 | 49 | |
| 50 | 50 | $taskInteration = new TaskInteration(); |
| 51 | 51 | $taskInteration->setTask($task); |
@@ -54,32 +54,32 @@ discard block |
||
| 54 | 54 | $taskInteration->setBody($message->getMessageContent()->getBody()); |
| 55 | 55 | $taskInteration->setRegisteredBy($registredBy); |
| 56 | 56 | if ($file) |
| 57 | - $taskInteration->setFile($file); |
|
| 57 | + $taskInteration->setFile($file); |
|
| 58 | 58 | |
| 59 | 59 | $this->manager->persist($taskInteration); |
| 60 | 60 | $this->manager->flush(); |
| 61 | 61 | |
| 62 | 62 | return $taskInteration; |
| 63 | - } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - public function discoveryOpenTask(People $provider, People $registredBy, string $type): Task |
|
| 66 | - { |
|
| 65 | + public function discoveryOpenTask(People $provider, People $registredBy, string $type): Task |
|
| 66 | + { |
|
| 67 | 67 | |
| 68 | 68 | $openStatus = $this->statusService->discoveryStatus('open', 'open', $type); |
| 69 | 69 | $pendingStatus = $this->statusService->discoveryStatus('pending', 'pending', $type); |
| 70 | 70 | |
| 71 | 71 | $task = $this->manager->getRepository(Task::class)->findOneBy([ |
| 72 | - 'taskStatus' => [$openStatus, $pendingStatus], |
|
| 73 | - 'provider' => $provider, |
|
| 74 | - 'registeredBy' => $registredBy, |
|
| 75 | - 'type' => $type |
|
| 72 | + 'taskStatus' => [$openStatus, $pendingStatus], |
|
| 73 | + 'provider' => $provider, |
|
| 74 | + 'registeredBy' => $registredBy, |
|
| 75 | + 'type' => $type |
|
| 76 | 76 | ]); |
| 77 | 77 | |
| 78 | 78 | if (!$task) { |
| 79 | - $task = new Task(); |
|
| 80 | - $task->setRegisteredBy($registredBy); |
|
| 81 | - $task->setProvider($provider); |
|
| 82 | - $task->settype($type); |
|
| 79 | + $task = new Task(); |
|
| 80 | + $task->setRegisteredBy($registredBy); |
|
| 81 | + $task->setProvider($provider); |
|
| 82 | + $task->settype($type); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | $task->setTaskStatus($openStatus); |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | $this->manager->flush(); |
| 88 | 88 | |
| 89 | 89 | return $task; |
| 90 | - } |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - public function prePersist(TaskInteration $taskInteration): TaskInteration |
|
| 93 | - { |
|
| 92 | + public function prePersist(TaskInteration $taskInteration): TaskInteration |
|
| 93 | + { |
|
| 94 | 94 | if (!$taskInteration->getRegisteredBy()) |
| 95 | - $taskInteration->setRegisteredBy($this->security->getToken()->getUser()->getPeople()); |
|
| 95 | + $taskInteration->setRegisteredBy($this->security->getToken()->getUser()->getPeople()); |
|
| 96 | 96 | return $taskInteration; |
| 97 | - } |
|
| 97 | + } |
|
| 98 | 98 | } |