@@ -14,8 +14,8 @@ |
||
14 | 14 | */ |
15 | 15 | class TaskRepository extends ServiceEntityRepository |
16 | 16 | { |
17 | - public function __construct(ManagerRegistry $registry) |
|
18 | - { |
|
17 | + public function __construct(ManagerRegistry $registry) |
|
18 | + { |
|
19 | 19 | parent::__construct($registry, Task::class); |
20 | - } |
|
20 | + } |
|
21 | 21 | } |
@@ -14,8 +14,8 @@ |
||
14 | 14 | */ |
15 | 15 | class TaskInterationRepository extends ServiceEntityRepository |
16 | 16 | { |
17 | - public function __construct(ManagerRegistry $registry) |
|
18 | - { |
|
17 | + public function __construct(ManagerRegistry $registry) |
|
18 | + { |
|
19 | 19 | parent::__construct($registry, TaskInteration::class); |
20 | - } |
|
20 | + } |
|
21 | 21 | } |
@@ -30,7 +30,7 @@ |
||
30 | 30 | 'ddd' => substr($number, 2, 2), |
31 | 31 | 'phone' => substr($number, 4) |
32 | 32 | ]; |
33 | - $registredBy = $this->peopleService->discoveryPeople(null, null, $phone, $name, null); |
|
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 | } |
@@ -40,12 +40,13 @@ discard block |
||
40 | 40 | |
41 | 41 | $file = null; |
42 | 42 | $media = $message->getMessageContent()->getMedia(); |
43 | - if ($media) |
|
44 | - $file = $this->fileService->addFile( |
|
43 | + if ($media) { |
|
44 | + $file = $this->fileService->addFile( |
|
45 | 45 | $registredBy, |
46 | 46 | pack("C*", ...$media->getData()), |
47 | 47 | $type |
48 | 48 | ); |
49 | + } |
|
49 | 50 | |
50 | 51 | $taskInteration = new TaskInteration(); |
51 | 52 | $taskInteration->setTask($task); |
@@ -53,8 +54,9 @@ discard block |
||
53 | 54 | $taskInteration->setVisibility($visibility); |
54 | 55 | $taskInteration->setBody($message->getMessageContent()->getBody()); |
55 | 56 | $taskInteration->setRegisteredBy($registredBy); |
56 | - if ($file) |
|
57 | - $taskInteration->setFile($file); |
|
57 | + if ($file) { |
|
58 | + $taskInteration->setFile($file); |
|
59 | + } |
|
58 | 60 | |
59 | 61 | $this->manager->persist($taskInteration); |
60 | 62 | $this->manager->flush(); |
@@ -91,8 +93,9 @@ discard block |
||
91 | 93 | |
92 | 94 | public function prePersist(TaskInteration $taskInteration): TaskInteration |
93 | 95 | { |
94 | - if (!$taskInteration->getRegisteredBy()) |
|
95 | - $taskInteration->setRegisteredBy($this->security->getToken()->getUser()->getPeople()); |
|
96 | + if (!$taskInteration->getRegisteredBy()) { |
|
97 | + $taskInteration->setRegisteredBy($this->security->getToken()->getUser()->getPeople()); |
|
98 | + } |
|
96 | 99 | return $taskInteration; |
97 | 100 | } |
98 | 101 | } |
@@ -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 | - 'registredBy' => $registredBy, |
|
75 | - 'type' => $type |
|
72 | + 'taskStatus' => [$openStatus, $pendingStatus], |
|
73 | + 'provider' => $provider, |
|
74 | + 'registredBy' => $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 | } |
@@ -13,21 +13,21 @@ discard block |
||
13 | 13 | |
14 | 14 | class TaskService |
15 | 15 | { |
16 | - private $request; |
|
16 | + private $request; |
|
17 | 17 | |
18 | - public function __construct( |
|
18 | + public function __construct( |
|
19 | 19 | private EntityManagerInterface $manager, |
20 | 20 | private Security $security, |
21 | 21 | private RequestStack $requestStack, |
22 | 22 | private StatusService $statusService, |
23 | 23 | private PeopleService $peopleService, |
24 | 24 | private FileService $fileService |
25 | - ) { |
|
25 | + ) { |
|
26 | 26 | $this->request = $this->requestStack->getCurrentRequest(); |
27 | - } |
|
27 | + } |
|
28 | 28 | |
29 | - public function securityFilter(QueryBuilder $queryBuilder, $resourceClass = null, $applyTo = null, $rootAlias = null): void |
|
30 | - { |
|
29 | + public function securityFilter(QueryBuilder $queryBuilder, $resourceClass = null, $applyTo = null, $rootAlias = null): void |
|
30 | + { |
|
31 | 31 | |
32 | 32 | /* |
33 | 33 | $companies = $this->peopleService->getMyCompanies(); |
@@ -36,5 +36,5 @@ discard block |
||
36 | 36 | */ |
37 | 37 | |
38 | 38 | //echo $queryBuilder->getQuery()->getSQL(); |
39 | - } |
|
39 | + } |
|
40 | 40 | } |