activity: fix type hinting in activity form

This commit is contained in:
nobohan 2021-12-03 14:34:21 +01:00
parent 6e521642a4
commit d2704ad7e6

View File

@ -260,6 +260,11 @@ class ActivityType extends AbstractType
return implode(',', $personIds);
},
function (?string $personsAsString): array {
if (null === $personsAsString) {
return [];
}
return array_map(
fn (string $id): ?Person => $this->om->getRepository(Person::class)->findOneBy(['id' => (int) $id]),
explode(',', $personsAsString)
@ -282,6 +287,10 @@ class ActivityType extends AbstractType
return implode(',', $thirdpartyIds);
},
function (?string $thirdpartyAsString): array {
if (null === $thirdpartyAsString) {
return [];
}
return array_map(
fn (string $id): ?ThirdParty => $this->om->getRepository(ThirdParty::class)->findOneBy(['id' => (int) $id]),
explode(',', $thirdpartyAsString)
@ -315,6 +324,9 @@ class ActivityType extends AbstractType
return implode(',', $userIds);
},
function (?string $usersAsString): array {
if (null === $socialActionsAsString) {
return [];
}
return array_map(
fn (string $id): ?User => $this->om->getRepository(User::class)->findOneBy(['id' => (int) $id]),
explode(',', $usersAsString)
@ -379,7 +391,7 @@ class ActivityType extends AbstractType
$timezoneUTC = new DateTimeZone('GMT');
/** @var DateTime $data */
$data = $formEvent->getData() === null ?
DateTime::createFromFormat('U', 300) :
DateTime::createFromFormat('U', '300') :
$formEvent->getData();
$seconds = $data->getTimezone()->getOffset($data);
$data->setTimeZone($timezoneUTC);