mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix cs
This commit is contained in:
parent
93c5e83454
commit
f513749780
@ -407,6 +407,7 @@ final class ActivityController extends AbstractController
|
||||
if (array_key_exists('usersId', $activityData) && $activityType->getUsersVisible() > 0) {
|
||||
foreach ($activityData['usersId'] as $userId) {
|
||||
$user = $this->userRepository->find($userId);
|
||||
|
||||
if (null !== $user) {
|
||||
$entity->addUser($user);
|
||||
}
|
||||
|
@ -309,50 +309,6 @@ class CalendarController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/calendar/calendar/{id}/to-activity", name="chill_calendar_calendar_to_activity")
|
||||
*/
|
||||
public function toActivity(Request $request, Calendar $calendar): RedirectResponse
|
||||
{
|
||||
$personsId = array_map(
|
||||
static fn (Person $p): int => $p->getId(),
|
||||
$calendar->getPersons()->toArray()
|
||||
);
|
||||
|
||||
$professionalsId = array_map(
|
||||
static fn (ThirdParty $thirdParty): ?int => $thirdParty->getId(),
|
||||
$calendar->getProfessionals()->toArray()
|
||||
);
|
||||
|
||||
$usersId = array_map(
|
||||
static fn (User $user): ?int => $user->getId(),
|
||||
array_merge($calendar->getUsers()->toArray(), [$calendar->getMainUser()])
|
||||
);
|
||||
|
||||
$durationTime = $calendar->getEndDate()->diff($calendar->getStartDate());
|
||||
$durationTimeInMinutes = $durationTime->days * 1440 + $durationTime->h * 60 + $durationTime->i;
|
||||
|
||||
$activityData = [
|
||||
'calendarId' => $calendar->getId(),
|
||||
'personsId' => $personsId,
|
||||
'professionalsId' => $professionalsId,
|
||||
'usersId' => $usersId,
|
||||
'date' => $calendar->getStartDate()->format('Y-m-d'),
|
||||
'durationTime' => $durationTimeInMinutes,
|
||||
'location' => $calendar->getLocation() ? $calendar->getLocation()->getId() : null,
|
||||
'comment' => $calendar->getComment()->getComment(),
|
||||
];
|
||||
|
||||
return $this->redirectToRoute(
|
||||
'chill_activity_activity_new',
|
||||
[
|
||||
'accompanying_period_id' => $calendar->getAccompanyingPeriod()->getId(),
|
||||
'activityData' => $activityData,
|
||||
'returnPath' => $request->query->get('returnPath', null),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a calendar item.
|
||||
*
|
||||
@ -424,6 +380,50 @@ class CalendarController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/calendar/calendar/{id}/to-activity", name="chill_calendar_calendar_to_activity")
|
||||
*/
|
||||
public function toActivity(Request $request, Calendar $calendar): RedirectResponse
|
||||
{
|
||||
$personsId = array_map(
|
||||
static fn (Person $p): int => $p->getId(),
|
||||
$calendar->getPersons()->toArray()
|
||||
);
|
||||
|
||||
$professionalsId = array_map(
|
||||
static fn (ThirdParty $thirdParty): ?int => $thirdParty->getId(),
|
||||
$calendar->getProfessionals()->toArray()
|
||||
);
|
||||
|
||||
$usersId = array_map(
|
||||
static fn (User $user): ?int => $user->getId(),
|
||||
array_merge($calendar->getUsers()->toArray(), [$calendar->getMainUser()])
|
||||
);
|
||||
|
||||
$durationTime = $calendar->getEndDate()->diff($calendar->getStartDate());
|
||||
$durationTimeInMinutes = $durationTime->days * 1440 + $durationTime->h * 60 + $durationTime->i;
|
||||
|
||||
$activityData = [
|
||||
'calendarId' => $calendar->getId(),
|
||||
'personsId' => $personsId,
|
||||
'professionalsId' => $professionalsId,
|
||||
'usersId' => $usersId,
|
||||
'date' => $calendar->getStartDate()->format('Y-m-d'),
|
||||
'durationTime' => $durationTimeInMinutes,
|
||||
'location' => $calendar->getLocation() ? $calendar->getLocation()->getId() : null,
|
||||
'comment' => $calendar->getComment()->getComment(),
|
||||
];
|
||||
|
||||
return $this->redirectToRoute(
|
||||
'chill_activity_activity_new',
|
||||
[
|
||||
'accompanying_period_id' => $calendar->getAccompanyingPeriod()->getId(),
|
||||
'activityData' => $activityData,
|
||||
'returnPath' => $request->query->get('returnPath', null),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
private function buildListFilterOrder(): FilterOrderHelper
|
||||
{
|
||||
$filterOrder = $this->filterOrderHelperFactory->create(self::class);
|
||||
|
@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\CalendarBundle\Messenger\Handler;
|
||||
|
||||
use Chill\CalendarBundle\Messenger\Message\CalendarRemovedMessage;
|
||||
@ -9,21 +18,18 @@ use Chill\MainBundle\Repository\UserRepositoryInterface;
|
||||
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
|
||||
|
||||
/**
|
||||
* Handle the deletion of calendar
|
||||
* Handle the deletion of calendar.
|
||||
*
|
||||
* @AsMessageHandler
|
||||
*/
|
||||
class CalendarRemoveHandler implements MessageHandlerInterface
|
||||
{
|
||||
private RemoteCalendarConnectorInterface $remoteCalendarConnector;
|
||||
private CalendarRangeRepository $calendarRangeRepository;
|
||||
|
||||
private RemoteCalendarConnectorInterface $remoteCalendarConnector;
|
||||
|
||||
private UserRepositoryInterface $userRepository;
|
||||
|
||||
/**
|
||||
* @param RemoteCalendarConnectorInterface $remoteCalendarConnector
|
||||
* @param CalendarRangeRepository $calendarRangeRepository
|
||||
* @param UserRepositoryInterface $userRepository
|
||||
*/
|
||||
public function __construct(RemoteCalendarConnectorInterface $remoteCalendarConnector, CalendarRangeRepository $calendarRangeRepository, UserRepositoryInterface $userRepository)
|
||||
{
|
||||
$this->remoteCalendarConnector = $remoteCalendarConnector;
|
||||
|
@ -16,6 +16,8 @@ use Chill\MainBundle\Entity\User;
|
||||
|
||||
class CalendarRemovedMessage
|
||||
{
|
||||
private ?int $associatedCalendarRangeId = null;
|
||||
|
||||
private ?int $byUserId = null;
|
||||
|
||||
private int $calendarUserId;
|
||||
@ -24,8 +26,6 @@ class CalendarRemovedMessage
|
||||
|
||||
private string $remoteId;
|
||||
|
||||
private ?int $associatedCalendarRangeId = null;
|
||||
|
||||
public function __construct(Calendar $calendar, ?User $byUser)
|
||||
{
|
||||
$this->remoteId = $calendar->getRemoteId();
|
||||
@ -41,6 +41,11 @@ class CalendarRemovedMessage
|
||||
}
|
||||
}
|
||||
|
||||
public function getAssociatedCalendarRangeId(): ?int
|
||||
{
|
||||
return $this->associatedCalendarRangeId;
|
||||
}
|
||||
|
||||
public function getByUserId(): ?int
|
||||
{
|
||||
return $this->byUserId;
|
||||
@ -60,14 +65,4 @@ class CalendarRemovedMessage
|
||||
{
|
||||
return $this->remoteId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getAssociatedCalendarRangeId(): ?int
|
||||
{
|
||||
return $this->associatedCalendarRangeId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -149,7 +149,6 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function removeCalendarRange(string $remoteId, array $remoteAttributes, User $user): void
|
||||
{
|
||||
if ('' === $remoteId) {
|
||||
|
@ -40,7 +40,6 @@ class NullRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public function removeCalendarRange(string $remoteId, array $remoteAttributes, User $user): void
|
||||
{
|
||||
}
|
||||
|
@ -39,10 +39,10 @@ interface RemoteCalendarConnectorInterface
|
||||
*/
|
||||
public function listEventsForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate): array;
|
||||
|
||||
public function removeCalendarRange(string $remoteId, array $remoteAttributes, User $user): void;
|
||||
|
||||
public function removeCalendar(string $remoteId, array $remoteAttributes, User $user, ?CalendarRange $associatedCalendarRange = null): void;
|
||||
|
||||
public function removeCalendarRange(string $remoteId, array $remoteAttributes, User $user): void;
|
||||
|
||||
/**
|
||||
* @param array<array{inviteId: int, userId: int, userEmail: int, userLabel: string}> $oldInvites
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user