|
|
@@ -71,10 +71,10 @@ class DolibarrSyncService
|
|
|
*
|
|
|
* Returns an array of DolibarrSyncOperations
|
|
|
*
|
|
|
+ * @param callable | null $progressionCallback A callback method for indicating the current progression of the process;
|
|
|
+ * Shall accept two integer arguments: current progression, and total.
|
|
|
* @return array<BaseRestOperation>
|
|
|
* @throws Exception
|
|
|
- * @var callable | null $progressionCallback A callback method for indicating the current progression of the process;
|
|
|
- * Shall accept two integer arguments: current progression, and total.
|
|
|
*
|
|
|
* @noinspection NullPointerExceptionInspection
|
|
|
*/
|
|
|
@@ -233,8 +233,8 @@ class DolibarrSyncService
|
|
|
'lastname' => trim($person->getName()),
|
|
|
'firstname' => trim($person->getGivenName()),
|
|
|
'email' => $contact?->getEmail(),
|
|
|
- 'phone_pro' => $contact?->getTelphone() ? $this->formatPhoneNumber($contact?->getTelphone()) : null,
|
|
|
- 'phone_mobile' => $contact?->getMobilPhone() ? $this->formatPhoneNumber($contact?->getMobilPhone()): null,
|
|
|
+ 'phone_pro' => $contact?->getTelphone() ? $this->formatPhoneNumber($contact->getTelphone()) : null,
|
|
|
+ 'phone_mobile' => $contact?->getMobilPhone() ? $this->formatPhoneNumber($contact->getMobilPhone()): null,
|
|
|
'poste' => $this->formatContactPosition($missions, $person->getGender()),
|
|
|
'statut' => '1'
|
|
|
];
|
|
|
@@ -318,10 +318,10 @@ class DolibarrSyncService
|
|
|
* Returns an array of DolibarrSyncOperations
|
|
|
*
|
|
|
* @param array<BaseRestOperation> $operations
|
|
|
+ * @param callable | null $progressionCallback A callback method for indicating the current progression of the process;
|
|
|
+ * Shall accept two integer arguments: current progression, and total.
|
|
|
* @return array<BaseRestOperation>
|
|
|
* @throws Exception
|
|
|
- *@var callable | null $progressionCallback A callback method for indicating the current progression of the process;
|
|
|
- * Shall accept two integer arguments: current progression, and total.
|
|
|
*/
|
|
|
public function execute(array $operations, ?callable $progressionCallback = null): array
|
|
|
{
|
|
|
@@ -361,7 +361,7 @@ class DolibarrSyncService
|
|
|
try {
|
|
|
$this->validateResponse($response, $operation);
|
|
|
} catch (RuntimeException $e) {
|
|
|
- $this->logger->warning($e);
|
|
|
+ $this->logger->warning($e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -369,7 +369,7 @@ class DolibarrSyncService
|
|
|
} catch (RuntimeException $e) {
|
|
|
$this->logger->error('Error while executing operation : ' . $operation);
|
|
|
$this->logger->error(implode("\n", $operation->getChangeLog()));
|
|
|
- $this->logger->error($e);
|
|
|
+ $this->logger->error($e->getMessage());
|
|
|
$errors++;
|
|
|
}
|
|
|
|
|
|
@@ -408,7 +408,7 @@ class DolibarrSyncService
|
|
|
/**
|
|
|
* Get the client societies dolibarr and index them by organization id
|
|
|
*
|
|
|
- * @return array An index of the form [$organizationId => $dolibarrData]
|
|
|
+ * @return array<mixed> An index of the form [$organizationId => $dolibarrData]
|
|
|
*/
|
|
|
protected function getDolibarrSocietiesIndex(): array
|
|
|
{
|
|
|
@@ -440,7 +440,7 @@ class DolibarrSyncService
|
|
|
*
|
|
|
* Index is the form: [$organizationId => [$accessId => [$mission, $mission...], $accessId...], $organizationId2...]
|
|
|
*
|
|
|
- * @return array
|
|
|
+ * @return array<mixed>
|
|
|
*/
|
|
|
protected function getActiveMembersIndex(): array
|
|
|
{
|
|
|
@@ -467,9 +467,9 @@ class DolibarrSyncService
|
|
|
*
|
|
|
* If none are found with the person id, try to find one with the same full name and no person id
|
|
|
*
|
|
|
- * @param array $dolibarrContacts
|
|
|
+ * @param array<mixed> $dolibarrContacts
|
|
|
* @param Person $person
|
|
|
- * @return array|null
|
|
|
+ * @return array<mixed>|null
|
|
|
*/
|
|
|
protected function findDolibarrContactFor(array $dolibarrContacts, Person $person): ?array
|
|
|
{
|
|
|
@@ -488,8 +488,8 @@ class DolibarrSyncService
|
|
|
!($contactData["array_options"]["options_2iopen_person_id"] ?? null) &&
|
|
|
$person->getName() !== null &&
|
|
|
$person->getGivenName() !== null &&
|
|
|
- strtolower($person->getName() ?? '') === strtolower($contactData["lastname"] ?? '') &&
|
|
|
- strtolower($person->getGivenName() ?? '') === strtolower($contactData["firstname"] ?? '')
|
|
|
+ strtolower($person->getName()) === strtolower($contactData["lastname"] ?? '') &&
|
|
|
+ strtolower($person->getGivenName()) === strtolower($contactData["firstname"] ?? '')
|
|
|
) {
|
|
|
return $contactData;
|
|
|
}
|
|
|
@@ -504,8 +504,8 @@ class DolibarrSyncService
|
|
|
* As far as we know, there is no harm here to replace every empty string value by a null value
|
|
|
* (no loss of information)
|
|
|
*
|
|
|
- * @param array|null $data
|
|
|
- * @return array|null
|
|
|
+ * @param array<mixed>|null $data
|
|
|
+ * @return array<mixed>|null
|
|
|
*/
|
|
|
protected function sanitizeDolibarrData(?array $data): ?array
|
|
|
{
|
|
|
@@ -630,8 +630,8 @@ class DolibarrSyncService
|
|
|
/**
|
|
|
* Returns the number of accesses possessing at least one of the missions
|
|
|
*
|
|
|
- * @param array $missions A list of missions
|
|
|
- * @param array $members An organization members as returned by getActiveMembersIndex: [$accessID => [$missions...]]
|
|
|
+ * @param array<mixed> $missions A list of missions
|
|
|
+ * @param array<mixed> $members An organization members as returned by getActiveMembersIndex: [$accessID => [$missions...]]
|
|
|
* @return int
|
|
|
*/
|
|
|
protected function countWithMission(array $missions, array $members): int
|
|
|
@@ -670,7 +670,7 @@ class DolibarrSyncService
|
|
|
/**
|
|
|
* Format the contact position from its gender and missions
|
|
|
*
|
|
|
- * @param array $missions
|
|
|
+ * @param list<string> $missions
|
|
|
* @param string|null $gender
|
|
|
* @return string
|
|
|
*/
|
|
|
@@ -733,7 +733,7 @@ class DolibarrSyncService
|
|
|
* In the case of a validation error, throw an HttpException
|
|
|
*
|
|
|
* @param ResponseInterface $response
|
|
|
- * @param BaseRestOperation $operation
|
|
|
+ * @param UpdateOperation | CreateOperation $operation
|
|
|
* @throws RuntimeException
|
|
|
*/
|
|
|
protected function validateResponse(ResponseInterface $response, UpdateOperation | CreateOperation $operation): void
|