apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -37,11 +37,8 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Contracts\Translation\TranslatorInterface;
use function count;
/**
* Class EventController.
*/
@@ -90,7 +87,6 @@ class EventController extends AbstractController
}
/**
* @param $event_id
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/{event_id}/delete", name="chill_event__event_delete", requirements={"event_id"="\d+"}, methods={"GET", "DELETE"})
*/
public function deleteAction($event_id, Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
@@ -109,7 +105,7 @@ class EventController extends AbstractController
$form = $this->createDeleteForm($event_id);
if ($request->getMethod() === Request::METHOD_DELETE) {
if (Request::METHOD_DELETE === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {
@@ -142,9 +138,8 @@ class EventController extends AbstractController
/**
* Displays a form to edit an existing Event entity.
*
* @param $event_id
*
* @return \Symfony\Component\HttpFoundation\Response
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/{event_id}/edit", name="chill_event__event_edit")
*/
public function editAction($event_id)
@@ -168,11 +163,10 @@ class EventController extends AbstractController
/**
* List events subscriptions for a person.
*
* @param $person_id
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Doctrine\ORM\NonUniqueResultException
*
* @return \Symfony\Component\HttpFoundation\Response
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/{person_id}/list", name="chill_event__list_by_person", methods={"GET"})
*/
public function listByPersonAction($person_id)
@@ -233,9 +227,8 @@ class EventController extends AbstractController
/**
* Displays a form to create a new Event entity.
*
* @param Center $center
*
* @return \Symfony\Component\HttpFoundation\Response
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/new", name="chill_event__event_new", methods={"GET", "POST"})
*/
public function newAction(?Center $center, Request $request)
@@ -270,6 +263,7 @@ class EventController extends AbstractController
/**
* First step of new Event form.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/new/pick-center", name="chill_event__event_new_pickcenter", options={null})
*/
public function newPickCenterAction()
@@ -281,7 +275,7 @@ class EventController extends AbstractController
*/
$centers = $this->authorizationHelper->getReachableCenters($this->getUser(), $role);
if (count($centers) === 1) {
if (1 === \count($centers)) {
return $this->redirectToRoute('chill_event__event_new', [
'center_id' => $centers[0]->getId(),
]);
@@ -316,9 +310,10 @@ class EventController extends AbstractController
*
* @ParamConverter("event", options={"id": "event_id"})
*
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return \Symfony\Component\HttpFoundation\Response
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/{event_id}/show", name="chill_event__event_show")
*/
public function showAction(Event $event, Request $request)
@@ -351,7 +346,6 @@ class EventController extends AbstractController
/**
* Edits an existing Event entity.
*
* @param $event_id
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/{event_id}/update", name="chill_event__event_update", methods={"POST", "PUT"})
*/
public function updateAction(Request $request, $event_id): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
@@ -493,9 +487,9 @@ class EventController extends AbstractController
}
/**
* @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return Spreadsheet
*
* @throws \PhpOffice\PhpSpreadsheet\Exception
*/
protected function createExportSpreadsheet(Event $event)
{
@@ -527,14 +521,14 @@ class EventController extends AbstractController
$columnLetter = 'A';
foreach ($columnNames as $columnName) {
$sheet->setCellValue($columnLetter . '8', $columnName);
$sheet->setCellValue($columnLetter.'8', $columnName);
++$columnLetter;
}
$columnValues = [];
foreach ($event->getParticipations() as $participation) {
/** @var Participation $participation */
/* @var Participation $participation */
$columnValues[] = [
$participation->getPerson()->getId(),
$participation->getPerson()->getFirstname(),
@@ -553,7 +547,7 @@ class EventController extends AbstractController
$columnLetter = 'A';
foreach ($columnValue as $value) {
$sheet->setCellValue($columnLetter . $i, $value);
$sheet->setCellValue($columnLetter.$i, $value);
++$columnLetter;
}
++$i;
@@ -563,9 +557,9 @@ class EventController extends AbstractController
}
/**
* @throws \PhpOffice\PhpSpreadsheet\Exception
*
* @return array
*
* @throws \PhpOffice\PhpSpreadsheet\Exception
*/
protected function exportParticipationsList(Event $event, Request $request)
{
@@ -575,7 +569,7 @@ class EventController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$format = $data['format'];
$filename = 'export_event' . $event->getId() . '_participations.' . $format;
$filename = 'export_event'.$event->getId().'_participations.'.$format;
$spreadsheet = $this->createExportSpreadsheet($event);
@@ -604,7 +598,7 @@ class EventController extends AbstractController
$response = new StreamedResponse();
$response->headers->set('Content-Type', $contentType);
$response->headers->set('Content-Disposition', 'attachment;filename="' . $filename . '"');
$response->headers->set('Content-Disposition', 'attachment;filename="'.$filename.'"');
$response->setPrivate();
$response->headers->addCacheControlDirective('no-cache', true);
$response->headers->addCacheControlDirective('must-revalidate', true);
@@ -639,8 +633,6 @@ class EventController extends AbstractController
}
/**
* @param $event_id
*
* @return \Symfony\Component\Form\FormInterface
*/
private function createDeleteForm($event_id)

View File

@@ -24,6 +24,7 @@ class EventTypeController extends AbstractController
{
/**
* Creates a new EventType entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/create", name="chill_eventtype_admin_create", methods={"POST"})
*/
public function createAction(Request $request)
@@ -48,6 +49,7 @@ class EventTypeController extends AbstractController
/**
* Deletes a EventType entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/{id}/delete", name="chill_eventtype_admin_delete", methods={"POST", "DELETE"})
*/
public function deleteAction(Request $request, mixed $id)
@@ -72,6 +74,7 @@ class EventTypeController extends AbstractController
/**
* Displays a form to edit an existing EventType entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/{id}/edit", name="chill_eventtype_admin_edit")
*/
public function editAction(mixed $id)
@@ -96,6 +99,7 @@ class EventTypeController extends AbstractController
/**
* Lists all EventType entities.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/", name="chill_eventtype_admin", options={null})
*/
public function indexAction()
@@ -111,6 +115,7 @@ class EventTypeController extends AbstractController
/**
* Displays a form to create a new EventType entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/new", name="chill_eventtype_admin_new")
*/
public function newAction()
@@ -126,6 +131,7 @@ class EventTypeController extends AbstractController
/**
* Finds and displays a EventType entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/{id}/show", name="chill_eventtype_admin_show")
*/
public function showAction(mixed $id)
@@ -148,6 +154,7 @@ class EventTypeController extends AbstractController
/**
* Edits an existing EventType entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/{id}/update", name="chill_eventtype_admin_update", methods={"POST", "PUT"})
*/
public function updateAction(Request $request, mixed $id)

View File

@@ -11,16 +11,12 @@ declare(strict_types=1);
namespace Chill\EventBundle\Controller;
use ArrayIterator;
use Chill\EventBundle\Entity\Event;
use Chill\EventBundle\Entity\Participation;
use Chill\EventBundle\Form\ParticipationType;
use Chill\EventBundle\Security\Authorization\ParticipationVoter;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ReadableCollection;
use LogicException;
use Psr\Log\LoggerInterface;
use RuntimeException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
@@ -28,8 +24,6 @@ use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use function count;
/**
* Class ParticipationController.
*/
@@ -41,15 +35,14 @@ class ParticipationController extends AbstractController
public function __construct(private readonly LoggerInterface $logger) {}
/**
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/create", name="chill_event_participation_create")
*/
public function createAction(Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
public function createAction(Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse
{
// test the request is correct
try {
$this->testRequest($request);
} catch (RuntimeException $ex) {
} catch (\RuntimeException $ex) {
$this->logger->warning($ex->getMessage());
return (new Response())
@@ -73,7 +66,7 @@ class ParticipationController extends AbstractController
return (new Response())
->setStatusCode(Response::HTTP_BAD_REQUEST)
->setContent("You must provide either 'person_id' or "
. "'persons_ids' argument in query");
."'persons_ids' argument in query");
}
/**
@@ -159,10 +152,7 @@ class ParticipationController extends AbstractController
return $form;
}
/**
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
*/
public function createMultiple(Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
public function createMultiple(Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse
{
$participations = $this->handleRequest($request, new Participation(), true);
@@ -202,10 +192,7 @@ class ParticipationController extends AbstractController
]);
}
/**
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
*/
public function createSingle(Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
public function createSingle(Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse
{
$participation = $this->handleRequest($request, new Participation(), false);
@@ -246,10 +233,9 @@ class ParticipationController extends AbstractController
/**
* @param int $participation_id
*
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/{participation_id}/delete", name="chill_event_participation_delete", requirements={"participation_id"="\d+"}, methods={"GET", "DELETE"})
*/
public function deleteAction($participation_id, Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
public function deleteAction($participation_id, Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse
{
$em = $this->getDoctrine()->getManager();
$participation = $em->getRepository(\Chill\EventBundle\Entity\Participation::class)->findOneBy([
@@ -265,7 +251,7 @@ class ParticipationController extends AbstractController
$form = $this->createDeleteForm($participation_id);
if ($request->getMethod() === Request::METHOD_DELETE) {
if (Request::METHOD_DELETE === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {
@@ -293,8 +279,9 @@ class ParticipationController extends AbstractController
/**
* Show an edit form for the participation with the given id.
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the participation is not found
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the participation is not found
* @throws \Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException if the user is not allowed to edit the participation
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/{participation_id}/edit", name="chill_event_participation_edit")
*/
public function editAction(int $participation_id): Response
@@ -327,10 +314,9 @@ class ParticipationController extends AbstractController
*
* @param int $event_id
*
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/{event_id}/edit_multiple", name="chill_event_participation_edit_multiple")
*/
public function editMultipleAction($event_id): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
public function editMultipleAction($event_id): Response|\Symfony\Component\HttpFoundation\RedirectResponse
{
$event = $this->getDoctrine()->getRepository(\Chill\EventBundle\Entity\Event::class)
->find($event_id);
@@ -341,13 +327,13 @@ class ParticipationController extends AbstractController
// check for ACL, on Event level and on Participation Level
$this->denyAccessUnlessGranted('CHILL_EVENT_SEE', $event, 'You are not allowed '
. 'to see this event');
.'to see this event');
foreach ($event->getParticipations() as $participation) {
$this->denyAccessUnlessGranted(
ParticipationVoter::UPDATE,
$participation,
'You are not allowed to update participation with id ' . $participation->getId()
'You are not allowed to update participation with id '.$participation->getId()
);
}
@@ -385,15 +371,14 @@ class ParticipationController extends AbstractController
* and decide if it should process a single or multiple participation. Depending
* on this, the appropriate layout and form.
*
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/new", name="chill_event_participation_new")
*/
public function newAction(Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
public function newAction(Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse
{
// test the request is correct
try {
$this->testRequest($request);
} catch (RuntimeException $ex) {
} catch (\RuntimeException $ex) {
$this->logger->warning($ex->getMessage());
return (new Response())
@@ -417,7 +402,7 @@ class ParticipationController extends AbstractController
return (new Response())
->setStatusCode(Response::HTTP_BAD_REQUEST)
->setContent("You must provide either 'person_id' or "
. "'persons_ids' argument in query");
."'persons_ids' argument in query");
}
/**
@@ -478,13 +463,13 @@ class ParticipationController extends AbstractController
}
$this->denyAccessUnlessGranted('CHILL_EVENT_SEE', $event, 'You are not allowed '
. 'to see this event');
.'to see this event');
foreach ($event->getParticipations() as $participation) {
$this->denyAccessUnlessGranted(
ParticipationVoter::UPDATE,
$participation,
'You are not allowed to update participation with id ' . $participation->getId()
'You are not allowed to update participation with id '.$participation->getId()
);
}
@@ -496,7 +481,7 @@ class ParticipationController extends AbstractController
$this->getDoctrine()->getManager()->flush();
$this->addFlash('success', $this->get('translator')->trans('The participations '
. 'have been successfully updated.'));
.'have been successfully updated.'));
return $this->redirectToRoute(
'chill_event__event_show',
@@ -551,10 +536,10 @@ class ParticipationController extends AbstractController
* If the request is multiple, the $participation object is cloned.
* Limitations: the $participation should not be persisted.
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the event/person is not found
* @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException if the user does not have access to event/person
* @return Participation|Participation[] return one single participation if $multiple == false
*
* @return Participation|Participations[] return one single participation if $multiple == false
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the event/person is not found
* @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException if the user does not have access to event/person
*/
protected function handleRequest(
Request $request,
@@ -564,8 +549,7 @@ class ParticipationController extends AbstractController
$em = $this->getDoctrine()->getManager();
if ($em->contains($participation)) {
throw new LogicException('The participation object should not be managed by '
. 'the object manager using the method ' . __METHOD__);
throw new \LogicException('The participation object should not be managed by the object manager using the method '.__METHOD__);
}
$event_id = $request->query->getInt('event_id', 0); // sf4 check:
@@ -576,7 +560,7 @@ class ParticipationController extends AbstractController
->find($event_id);
if (null === $event) {
throw $this->createNotFoundException('The event with id ' . $event_id . ' is not found');
throw $this->createNotFoundException('The event with id '.$event_id.' is not found');
}
$this->denyAccessUnlessGranted(
@@ -598,14 +582,14 @@ class ParticipationController extends AbstractController
foreach ($persons_ids as $person_id) {
// clone if we have to reuse the $participation
$participation = count($persons_ids) > 1 ? clone $participation : $participation;
$participation = \count($persons_ids) > 1 ? clone $participation : $participation;
if (null !== $person_id) {
$person = $em->getRepository(\Chill\PersonBundle\Entity\Person::class)
->find($person_id);
if (null === $person) {
throw $this->createNotFoundException('The person with id ' . $person_id . ' is not found');
throw $this->createNotFoundException('The person with id '.$person_id.' is not found');
}
$this->denyAccessUnlessGranted(
@@ -634,16 +618,14 @@ class ParticipationController extends AbstractController
*
* If all participations must be ignored, an error is shown and the method redirects
* to the event 'show' view with an appropriate flash message.
*
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
*/
protected function newMultiple(Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
protected function newMultiple(Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse
{
$participations = $this->handleRequest($request, new Participation(), true);
$ignoredParticipations = $newParticipations = [];
foreach ($participations as $participation) {
/** @var Participation $participation */
/* @var Participation $participation */
// check for authorization
$this->denyAccessUnlessGranted(
ParticipationVoter::CREATE,
@@ -652,7 +634,6 @@ class ParticipationController extends AbstractController
);
// create a collection of person's id participating to the event
/** @var \Doctrine\Common\Collections\ArrayCollection $peopleParticipating */
$peopleParticipating ??= $participation->getEvent()->getParticipations()->map(
static fn (Participation $p) => $p->getPerson()->getId()
);
@@ -673,7 +654,7 @@ class ParticipationController extends AbstractController
// if we do not have nay participants, redirect to event view
$this->addFlash('error', $this->get('translator')->trans(
'None of the requested people may participate '
. 'the event: they are maybe already participating.'
.'the event: they are maybe already participating.'
));
return $this->redirectToRoute('chill_event__event_show', [
@@ -681,7 +662,7 @@ class ParticipationController extends AbstractController
]);
}
if (count($newParticipations) > 1) {
if (\count($newParticipations) > 1) {
// if we have multiple participations, show a form with multiple participations
$form = $this->createCreateFormMultiple($newParticipations);
@@ -742,7 +723,7 @@ class ParticipationController extends AbstractController
* - `person_id` and `persons_ids` are **not** both present ;
* - `persons_id` is correct (contains only numbers and a ','.
*
* @throws RuntimeException if an error is detected
* @throws \RuntimeException if an error is detected
*/
protected function testRequest(Request $request)
{
@@ -751,28 +732,24 @@ class ParticipationController extends AbstractController
if (true === $single && true === $multiple) {
// we are not allowed to have both person_id and persons_ids
throw new RuntimeException("You are not allow to provide both 'person_id' and "
. "'persons_ids' simulaneously");
throw new \RuntimeException("You are not allow to provide both 'person_id' and 'persons_ids' simulaneously");
}
if (true === $multiple) {
$persons_ids = $request->query->get('persons_ids');
if (!preg_match('/^([0-9]{1,},{0,1}){1,}[0-9]{0,}$/', (string) $persons_ids)) {
throw new RuntimeException('The persons_ids value should '
. "contains int separated by ','");
throw new \RuntimeException('The persons_ids value should '."contains int separated by ','");
}
}
// check for event_id - this could be removed later
if ($request->query->has('event_id') === false) {
throw new RuntimeException('You must provide an event_id');
if (false === $request->query->has('event_id')) {
throw new \RuntimeException('You must provide an event_id');
}
}
/**
* @param $participation_id
*
* @return \Symfony\Component\Form\FormInterface
*/
private function createDeleteForm($participation_id)

View File

@@ -24,6 +24,7 @@ class RoleController extends AbstractController
{
/**
* Creates a new Role entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/create", name="chill_event_admin_role_create", methods={"POST"})
*/
public function createAction(Request $request)
@@ -48,6 +49,7 @@ class RoleController extends AbstractController
/**
* Deletes a Role entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/{id}/delete", name="chill_event_admin_role_delete", methods={"POST", "DELETE"})
*/
public function deleteAction(Request $request, mixed $id)
@@ -72,6 +74,7 @@ class RoleController extends AbstractController
/**
* Displays a form to edit an existing Role entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/{id}/edit", name="chill_event_admin_role_edit")
*/
public function editAction(mixed $id)
@@ -96,6 +99,7 @@ class RoleController extends AbstractController
/**
* Lists all Role entities.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/", name="chill_event_admin_role", options={null})
*/
public function indexAction()
@@ -111,6 +115,7 @@ class RoleController extends AbstractController
/**
* Displays a form to create a new Role entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/new", name="chill_event_admin_role_new")
*/
public function newAction()
@@ -126,6 +131,7 @@ class RoleController extends AbstractController
/**
* Finds and displays a Role entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/{id}/show", name="chill_event_admin_role_show")
*/
public function showAction(mixed $id)
@@ -148,6 +154,7 @@ class RoleController extends AbstractController
/**
* Edits an existing Role entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/{id}/update", name="chill_event_admin_role_update", methods={"POST", "PUT"})
*/
public function updateAction(Request $request, mixed $id)

View File

@@ -24,6 +24,7 @@ class StatusController extends AbstractController
{
/**
* Creates a new Status entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/create", name="chill_event_admin_status_create", methods={"POST"})
*/
public function createAction(Request $request)
@@ -48,6 +49,7 @@ class StatusController extends AbstractController
/**
* Deletes a Status entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/{id}/delete", name="chill_event_admin_status_delete", methods={"POST", "DELETE"})
*/
public function deleteAction(Request $request, mixed $id)
@@ -72,6 +74,7 @@ class StatusController extends AbstractController
/**
* Displays a form to edit an existing Status entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/{id}/edit", name="chill_event_admin_status_edit")
*/
public function editAction(mixed $id)
@@ -96,6 +99,7 @@ class StatusController extends AbstractController
/**
* Lists all Status entities.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/", name="chill_event_admin_status", options={null})
*/
public function indexAction()
@@ -111,6 +115,7 @@ class StatusController extends AbstractController
/**
* Displays a form to create a new Status entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/new", name="chill_event_admin_status_new")
*/
public function newAction()
@@ -126,6 +131,7 @@ class StatusController extends AbstractController
/**
* Finds and displays a Status entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/{id}/show", name="chill_event_admin_status_show")
*/
public function showAction(mixed $id)
@@ -148,6 +154,7 @@ class StatusController extends AbstractController
/**
* Edits an existing Status entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/{id}/update", name="chill_event_admin_status_update", methods={"POST", "PUT"})
*/
public function updateAction(Request $request, mixed $id)

View File

@@ -18,8 +18,6 @@ use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager;
use function in_array;
/**
* Add roles to existing groups.
*/
@@ -37,10 +35,10 @@ class LoadRolesACL extends AbstractFixture implements OrderedFixtureInterface
foreach (LoadScopes::$references as $scopeRef) {
$scope = $this->getReference($scopeRef);
//create permission group
// create permission group
switch ($permissionsGroup->getName()) {
case 'social':
if ($scope->getName()['en'] === 'administrative') {
if ('administrative' === $scope->getName()['en']) {
break 2; // we do not want any power on administrative
}
@@ -48,7 +46,7 @@ class LoadRolesACL extends AbstractFixture implements OrderedFixtureInterface
case 'administrative':
case 'direction':
if (in_array($scope->getName()['en'], ['administrative', 'social'], true)) {
if (\in_array($scope->getName()['en'], ['administrative', 'social'], true)) {
break 2; // we do not want any power on social or administrative
}
@@ -57,10 +55,10 @@ class LoadRolesACL extends AbstractFixture implements OrderedFixtureInterface
printf(
'Adding CHILL_EVENT_UPDATE & CHILL_EVENT_CREATE '
. '& CHILL_EVENT_PARTICIPATION_UPDATE & CHILL_EVENT_PARTICIPATION_CREATE '
. '& CHILL_EVENT_SEE & CHILL_EVENT_SEE_DETAILS '
. 'to %s '
. "permission group, scope '%s' \n",
.'& CHILL_EVENT_PARTICIPATION_UPDATE & CHILL_EVENT_PARTICIPATION_CREATE '
.'& CHILL_EVENT_SEE & CHILL_EVENT_SEE_DETAILS '
.'to %s '
."permission group, scope '%s' \n",
$permissionsGroup->getName(),
$scope->getName()['en']
);

View File

@@ -30,7 +30,7 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../config'));
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
$loader->load('services.yaml');
$loader->load('services/authorization.yaml');
$loader->load('services/controller.yaml');
@@ -70,7 +70,7 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface
*/
protected function prependRoute(ContainerBuilder $container)
{
//add routes for custom bundle
// add routes for custom bundle
$container->prependExtensionConfig('chill_main', [
'routing' => [
'resources' => [

View File

@@ -11,7 +11,6 @@ declare(strict_types=1);
namespace Chill\EventBundle\Entity;
use ArrayIterator;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\HasCenterInterface;
use Chill\MainBundle\Entity\HasScopeInterface;
@@ -21,13 +20,14 @@ use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Traversable;
/**
* Class Event.
*
* @ORM\Entity(repositoryClass="Chill\EventBundle\Repository\EventRepository")
*
* @ORM\Table(name="chill_event_event")
*
* @ORM\HasLifecycleCallbacks
*/
class Event implements HasCenterInterface, HasScopeInterface
@@ -48,10 +48,10 @@ class Event implements HasCenterInterface, HasScopeInterface
private ?\DateTime $date;
/**
* @var int
*
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
@@ -68,6 +68,7 @@ class Event implements HasCenterInterface, HasScopeInterface
/**
* @var Collection<Participation>
*
* @ORM\OneToMany(
* targetEntity="Chill\EventBundle\Entity\Participation",
* mappedBy="event")
@@ -118,7 +119,7 @@ class Event implements HasCenterInterface, HasScopeInterface
/**
* Get date.
*
* @return DateTime
* @return \DateTime
*/
public function getDate()
{
@@ -151,17 +152,15 @@ class Event implements HasCenterInterface, HasScopeInterface
}
/**
* @return Collection<Participation>
* @return Collection<int, Participation>
*/
public function getParticipations(): \ArrayIterator|\Doctrine\Common\Collections\Collection|\Traversable
public function getParticipations(): Collection
{
return new ArrayCollection(iterator_to_array($this->getParticipationsOrdered()));
}
/**
* Sort Collection of Participations.
*
* @return ArrayIterator|Traversable
*/
public function getParticipationsOrdered(): \ArrayIterator|\Traversable
{
@@ -169,7 +168,7 @@ class Event implements HasCenterInterface, HasScopeInterface
uasort($iterator, static fn ($first, $second) => strnatcasecmp((string) $first->getPerson()->getFirstName(), (string) $second->getPerson()->getFirstName()));
return new ArrayIterator($iterator);
return new \ArrayIterator($iterator);
}
/**
@@ -223,7 +222,7 @@ class Event implements HasCenterInterface, HasScopeInterface
*
* @return Event
*/
public function setDate(DateTime $date)
public function setDate(\DateTime $date)
{
$this->date = $date;

View File

@@ -19,34 +19,37 @@ use Doctrine\ORM\Mapping as ORM;
* Class EventType.
*
* @ORM\Entity
*
* @ORM\Table(name="chill_event_event_type")
*
* @ORM\HasLifecycleCallbacks
*/
class EventType
{
/**
* @var bool
* @ORM\Column(type="boolean", nullable=false)
*/
private bool $active = true;
/**
* @var int
*
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
/**
* @var array
*
* @ORM\Column(type="json")
*/
private $name;
/**
* @var Collection<Role>
*
* @ORM\OneToMany(
* targetEntity="Chill\EventBundle\Entity\Role",
* mappedBy="type")
@@ -55,6 +58,7 @@ class EventType
/**
* @var Collection<Status>
*
* @ORM\OneToMany(
* targetEntity="Chill\EventBundle\Entity\Status",
* mappedBy="type")

View File

@@ -11,7 +11,6 @@ declare(strict_types=1);
namespace Chill\EventBundle\Entity;
use ArrayAccess;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\HasCenterInterface;
use Chill\MainBundle\Entity\HasScopeInterface;
@@ -19,20 +18,19 @@ use Chill\MainBundle\Entity\Scope;
use Chill\PersonBundle\Entity\Person;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use RuntimeException;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function in_array;
/**
* Class Participation.
*
* @ORM\Entity(
* repositoryClass="Chill\EventBundle\Repository\ParticipationRepository")
*
* @ORM\Table(name="chill_event_participation")
*
* @ORM\HasLifecycleCallbacks
*/
class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterface
class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterface
{
/**
* @ORM\ManyToOne(
@@ -42,10 +40,10 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
private ?\Chill\EventBundle\Entity\Event $event = null;
/**
* @var int
*
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
@@ -75,9 +73,8 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
*/
public function getCenter()
{
if ($this->getEvent() === null) {
throw new RuntimeException('The event is not linked with this instance. '
. 'You should initialize the event with a valid center before.');
if (null === $this->getEvent()) {
throw new \RuntimeException('The event is not linked with this instance. You should initialize the event with a valid center before.');
}
return $this->getEvent()->getCenter();
@@ -85,10 +82,8 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
/**
* Get event.
*
* @return Event
*/
public function getEvent()
public function getEvent(): null|Event
{
return $this->event;
}
@@ -106,7 +101,7 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
/**
* Get lastUpdate.
*
* @return DateTime
* @return \DateTime
*/
public function getLastUpdate()
{
@@ -125,10 +120,8 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
/**
* Get role.
*
* @return Role
*/
public function getRole()
public function getRole(): null|Role
{
return $this->role;
}
@@ -138,9 +131,8 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
*/
public function getScope()
{
if ($this->getEvent() === null) {
throw new RuntimeException('The event is not linked with this instance. '
. 'You should initialize the event with a valid center before.');
if (null === $this->getEvent()) {
throw new \RuntimeException('The event is not linked with this instance. You should initialize the event with a valid center before.');
}
return $this->getEvent()->getCircle();
@@ -148,10 +140,8 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
/**
* Get status.
*
* @return Status
*/
public function getStatus()
public function getStatus(): null|Status
{
return $this->status;
}
@@ -164,7 +154,7 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
*/
public function isConsistent(ExecutionContextInterface $context)
{
if ($this->getEvent() === null || $this->getRole() === null || $this->getStatus() === null) {
if (null === $this->getEvent() || null === $this->getRole() || null === $this->getStatus()) {
return;
}
@@ -189,7 +179,7 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
public function offsetExists(mixed $offset): bool
{
return in_array($offset, [
return \in_array($offset, [
'person', 'role', 'status', 'event',
], true);
}
@@ -204,7 +194,7 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
'role' => $this->getRole(),
'status' => $this->getStatus(),
'event' => $this->getEvent(),
default => throw new \LogicException("this offset does not exists : " . $offset),
default => throw new \LogicException('this offset does not exists : '.$offset),
};
}
@@ -241,11 +231,9 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
/**
* Set event.
*
* @param Event $event
*
* @return Participation
*/
public function setEvent(?Event $event = null)
public function setEvent(Event $event = null)
{
if ($this->event !== $event) {
$this->update();
@@ -259,11 +247,9 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
/**
* Set person.
*
* @param Person $person
*
* @return Participation
*/
public function setPerson(?Person $person = null)
public function setPerson(Person $person = null)
{
if ($person !== $this->person) {
$this->update();
@@ -277,11 +263,9 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
/**
* Set role.
*
* @param Role $role
*
* @return Participation
*/
public function setRole(?Role $role = null)
public function setRole(Role $role = null)
{
if ($role !== $this->role) {
$this->update();
@@ -294,11 +278,9 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
/**
* Set status.
*
* @param Status $status
*
* @return Participation
*/
public function setStatus(?Status $status = null)
public function setStatus(Status $status = null)
{
if ($this->status !== $status) {
$this->update();
@@ -316,7 +298,7 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
*/
protected function update()
{
$this->lastUpdate = new DateTime('now');
$this->lastUpdate = new \DateTime('now');
return $this;
}

View File

@@ -17,28 +17,30 @@ use Doctrine\ORM\Mapping as ORM;
* Class Role.
*
* @ORM\Entity
*
* @ORM\Table(name="chill_event_role")
*
* @ORM\HasLifecycleCallbacks
*/
class Role
{
/**
* @var bool
* @ORM\Column(type="boolean", nullable=false)
*/
private bool $active = true;
/**
* @var int
*
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
/**
* @var array
*
* @ORM\Column(type="json")
*/
private $name;
@@ -121,11 +123,9 @@ class Role
/**
* Set type.
*
* @param EventType $type
*
* @return Role
*/
public function setType(?EventType $type = null)
public function setType(EventType $type = null)
{
$this->type = $type;

View File

@@ -17,28 +17,30 @@ use Doctrine\ORM\Mapping as ORM;
* Class Status.
*
* @ORM\Entity
*
* @ORM\Table(name="chill_event_status")
*
* @ORM\HasLifecycleCallbacks
*/
class Status
{
/**
* @var bool
* @ORM\Column(type="boolean", nullable=false)
*/
private bool $active = true;
/**
* @var int
*
* @ORM\Id
*
* @ORM\Column(name="id", type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
/**
* @var array
*
* @ORM\Column(type="json")
*/
private $name;
@@ -121,11 +123,9 @@ class Status
/**
* Set type.
*
* @param EventType $type
*
* @return Status
*/
public function setType(?EventType $type = null)
public function setType(EventType $type = null)
{
$this->type = $type;

View File

@@ -13,14 +13,9 @@ namespace Chill\EventBundle\Form\ChoiceLoader;
use Chill\EventBundle\Entity\Event;
use Doctrine\ORM\EntityRepository;
use RuntimeException;
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
use function call_user_func;
use function count;
use function in_array;
/**
* Class EventChoiceLoader.
*/
@@ -46,7 +41,7 @@ class EventChoiceLoader implements ChoiceLoaderInterface
*/
public function __construct(
EntityRepository $eventRepository,
?array $centers = null
array $centers = null
) {
$this->eventRepository = $eventRepository;
@@ -62,7 +57,7 @@ class EventChoiceLoader implements ChoiceLoaderInterface
{
return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList(
$this->lazyLoadedEvents,
static fn (Event $p) => call_user_func($value, $p)
static fn (Event $p) => \call_user_func($value, $p)
);
}
@@ -84,9 +79,9 @@ class EventChoiceLoader implements ChoiceLoaderInterface
if (
$this->hasCenterFilter()
&& !in_array($event->getCenter(), $this->centers, true)
&& !\in_array($event->getCenter(), $this->centers, true)
) {
throw new RuntimeException('chosen an event not in correct center');
throw new \RuntimeException('chosen an event not in correct center');
}
$choices[] = $event;
@@ -111,7 +106,7 @@ class EventChoiceLoader implements ChoiceLoaderInterface
continue;
}
$id = call_user_func($value, $choice);
$id = \call_user_func($value, $choice);
$values[] = $id;
$this->lazyLoadedEvents[$id] = $choice;
}
@@ -124,6 +119,6 @@ class EventChoiceLoader implements ChoiceLoaderInterface
*/
protected function hasCenterFilter()
{
return count($this->centers) > 0;
return \count($this->centers) > 0;
}
}

View File

@@ -19,7 +19,6 @@ use Chill\MainBundle\Form\Type\UserPickerType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Role\Role;
class EventType extends AbstractType
{

View File

@@ -14,7 +14,6 @@ namespace Chill\EventBundle\Form;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class EventTypeType extends AbstractType
{

View File

@@ -15,7 +15,6 @@ use Chill\EventBundle\Entity\EventType;
use Chill\EventBundle\Entity\Status;
use Chill\EventBundle\Form\Type\PickRoleType;
use Chill\EventBundle\Form\Type\PickStatusType;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

View File

@@ -13,12 +13,10 @@ namespace Chill\EventBundle\Form;
use Chill\EventBundle\Entity\EventType;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
final class RoleType extends AbstractType
{

View File

@@ -15,7 +15,6 @@ use Chill\EventBundle\Form\Type\PickEventTypeType;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class StatusType extends AbstractType
{

View File

@@ -19,21 +19,16 @@ use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\GroupCenter;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use RuntimeException;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Finder\Exception\AccessDeniedException;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
use function in_array;
use function is_array;
/**
* Class PickEventType.
*/
@@ -79,7 +74,7 @@ final class PickEventType extends AbstractType
// add the default options
$resolver->setDefaults([
'class' => Event::class,
'choice_label' => static fn (Event $e) => $e->getDate()->format('d/m/Y, H:i') . ' → ' .
'choice_label' => static fn (Event $e) => $e->getDate()->format('d/m/Y, H:i').' → '.
// $e->getType()->getName()['fr'] . ': ' . // display the type of event
$e->getName(),
'placeholder' => 'Pick an event',
@@ -128,18 +123,17 @@ final class PickEventType extends AbstractType
$selectedCenters = $centers;
} else {
$selectedCenters = [];
$optionsCenters = is_array($options['centers']) ?
$optionsCenters = \is_array($options['centers']) ?
$options['centers'] : [$options['centers']];
foreach ($optionsCenters as $c) {
// check that every member of the array is a center
if (!$c instanceof Center) {
throw new RuntimeException('Every member of the "centers" '
. 'option must be an instance of ' . Center::class);
throw new \RuntimeException('Every member of the "centers" option must be an instance of '.Center::class);
}
if (
!in_array($c->getId(), array_map(
!\in_array($c->getId(), array_map(
static fn (Center $c) => $c->getId(),
$centers
), true)

View File

@@ -14,9 +14,7 @@ namespace Chill\EventBundle\Form\Type;
use Chill\EventBundle\Entity\EventType;
use Chill\EventBundle\Entity\Role;
use Chill\EventBundle\Repository\RoleRepository;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -96,9 +94,9 @@ final class PickRoleType extends AbstractType
'data-event-type' => $r->getType()->getId(),
'data-link-category' => $r->getType()->getId(),
],
'choice_label' => static fn (Role $r) => $translatableStringHelper->localize($r->getName()) .
($r->getActive() === true ? '' :
' (' . $translator->trans('unactive') . ')'),
'choice_label' => static fn (Role $r) => $translatableStringHelper->localize($r->getName()).
(true === $r->getActive() ? '' :
' ('.$translator->trans('unactive').')'),
]);
}

View File

@@ -14,9 +14,7 @@ namespace Chill\EventBundle\Form\Type;
use Chill\EventBundle\Entity\EventType;
use Chill\EventBundle\Entity\Status;
use Chill\EventBundle\Repository\StatusRepository;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -93,9 +91,9 @@ final class PickStatusType extends AbstractType
'data-event-type' => $s->getType()->getId(),
'data-link-category' => $s->getType()->getId(),
],
'choice_label' => static fn (Status $s) => $translatableStringHelper->localize($s->getName()) .
($s->getActive() === true ? '' :
' (' . $translator->trans('unactive') . ')'),
'choice_label' => static fn (Status $s) => $translatableStringHelper->localize($s->getName()).
(true === $s->getActive() ? '' :
' ('.$translator->trans('unactive').')'),
]);
}

View File

@@ -13,7 +13,6 @@ namespace Chill\EventBundle\Repository;
use Chill\EventBundle\Entity\Event;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**

View File

@@ -28,8 +28,6 @@ class ParticipationRepository extends ServiceEntityRepository
/**
* Count number of participations per person.
*
* @param $person_id
*
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function countByPerson($person_id): int
@@ -44,13 +42,6 @@ class ParticipationRepository extends ServiceEntityRepository
/**
* Return paginated participations for a person and in reachables circles.
*
* @param $person_id
* @param $reachablesCircles
* @param $first
* @param $max
*
* @return mixed
*/
public function findByPersonInCircle($person_id, $reachablesCircles, $first, $max)
{

View File

@@ -21,5 +21,4 @@ class RoleRepository extends ServiceEntityRepository
{
parent::__construct($registry, Role::class);
}
}

View File

@@ -18,11 +18,7 @@ use Chill\MainBundle\Search\AbstractSearch;
use Chill\MainBundle\Search\SearchInterface;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Templating\EngineInterface as TemplatingEngine;
use function count;
/**
* Search within Events.
@@ -90,7 +86,7 @@ class EventSearch extends AbstractSearch
foreach ($search as $item) {
$results[] = [
'id' => $item->getId(),
'text' => $item->getDate()->format('d/m/Y, H:i') . ' → ' .
'text' => $item->getDate()->format('d/m/Y, H:i').' → '.
// $item->getType()->getName()['fr'] . ': ' . // display the type of event
$item->getName(),
];
@@ -115,7 +111,7 @@ class EventSearch extends AbstractSearch
'CHILL_EVENT_SEE'
);
if (count($reachableCenters) === 0) {
if (0 === \count($reachableCenters)) {
// add a clause to block all events
$where = $qb->expr()->isNull('e.center');
$qb->andWhere($where);
@@ -124,18 +120,18 @@ class EventSearch extends AbstractSearch
$orWhere = $qb->expr()->orX();
foreach ($reachableCenters as $center) {
$n = $n + 1;
++$n;
$circles = $this->authorizationHelper->getReachableScopes(
$this->security->getUser(),
'CHILL_EVENT_SEE',
$center
);
$where = $qb->expr()->andX(
$qb->expr()->eq('e.center', ':center_' . $n),
$qb->expr()->in('e.circle', ':circle_' . $n)
$qb->expr()->eq('e.center', ':center_'.$n),
$qb->expr()->in('e.circle', ':circle_'.$n)
);
$qb->setParameter('center_' . $n, $center);
$qb->setParameter('circle_' . $n, $circles);
$qb->setParameter('center_'.$n, $center);
$qb->setParameter('circle_'.$n, $circles);
$orWhere->add($where);
}
@@ -150,7 +146,7 @@ class EventSearch extends AbstractSearch
$name = $terms['name'] ?? $terms['_default'];
$where = $qb->expr()->like('UNACCENT(LOWER(e.name))', ':name');
$qb->setParameter('name', '%' . $name . '%');
$qb->setParameter('name', '%'.$name.'%');
$qb->andWhere($where);
}

View File

@@ -21,10 +21,6 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Psr\Log\LoggerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Security\Core\Role\Role;
use function count;
use function in_array;
/**
* Description of EventVoter.
@@ -90,14 +86,14 @@ class EventVoter extends AbstractChillVoter implements ProvideRoleHierarchyInter
public function supports($attribute, $subject)
{
return ($subject instanceof Event && in_array($attribute, self::ROLES, true))
|| ($subject instanceof Person && in_array($attribute, [self::CREATE, self::SEE], true))
return ($subject instanceof Event && \in_array($attribute, self::ROLES, true))
|| ($subject instanceof Person && \in_array($attribute, [self::CREATE, self::SEE], true))
|| (null === $subject && self::SEE === $attribute);
}
/**
* @param string $attribute
* @param Event $subject
* @param Event $subject
*
* @return bool
*/
@@ -121,7 +117,7 @@ class EventVoter extends AbstractChillVoter implements ProvideRoleHierarchyInter
$centers = $this->authorizationHelper
->getReachableCenters($token->getUser(), $attribute);
return count($centers) > 0;
return \count($centers) > 0;
if (!$this->accessDecisionManager->decide($token, [PersonVoter::SEE], $person)) {
return false;

View File

@@ -21,10 +21,6 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Psr\Log\LoggerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Security\Core\Role\Role;
use function count;
use function in_array;
class ParticipationVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
{
@@ -87,13 +83,13 @@ class ParticipationVoter extends AbstractChillVoter implements ProvideRoleHierar
public function supports($attribute, $subject)
{
return ($subject instanceof Participation && in_array($attribute, self::ROLES, true))
|| ($subject instanceof Person && in_array($attribute, [self::CREATE, self::SEE], true))
return ($subject instanceof Participation && \in_array($attribute, self::ROLES, true))
|| ($subject instanceof Person && \in_array($attribute, [self::CREATE, self::SEE], true))
|| (null === $subject && self::SEE === $attribute);
}
/**
* @param string $attribute
* @param string $attribute
* @param Participation $subject
*
* @return bool
@@ -118,7 +114,7 @@ class ParticipationVoter extends AbstractChillVoter implements ProvideRoleHierar
$centers = $this->authorizationHelper
->getReachableCenters($token->getUser(), $attribute);
return count($centers) > 0;
return \count($centers) > 0;
if (!$this->accessDecisionManager->decide($token, [PersonVoter::SEE], $person)) {
return false;

View File

@@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
* @internal
*
* @coversNothing
*/
final class EventControllerTest extends WebTestCase

View File

@@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
* @internal
*
* @coversNothing
*/
final class EventTypeControllerTest extends WebTestCase

View File

@@ -13,12 +13,12 @@ namespace Chill\EventBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use function count;
use function in_array;
/**
* Test the creation of participation controller.
*
* @internal
*
* @coversNothing
*/
final class ParticipationControllerTest extends WebTestCase
@@ -83,7 +83,7 @@ final class ParticipationControllerTest extends WebTestCase
400,
$this->client->getResponse()->getStatusCode(),
'Test that /fr/event/participation/create fail if '
. 'both person_id and persons_ids are missing'
.'both person_id and persons_ids are missing'
);
// having both person_id and persons_ids
@@ -103,7 +103,7 @@ final class ParticipationControllerTest extends WebTestCase
400,
$this->client->getResponse()->getStatusCode(),
'test that /fr/event/participation/create fail if both person_id and '
. 'persons_ids are set'
.'persons_ids are set'
);
// missing event_id
@@ -141,7 +141,7 @@ final class ParticipationControllerTest extends WebTestCase
/** @var \Chill\EventBundle\Entity\Event $event */
$event = $this->getRandomEventWithMultipleParticipations();
$crawler = $this->client->request('GET', '/fr/event/participation/' . $event->getId() .
$crawler = $this->client->request('GET', '/fr/event/participation/'.$event->getId().
'/edit_multiple');
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@@ -157,7 +157,7 @@ final class ParticipationControllerTest extends WebTestCase
]);
$this->assertTrue($this->client->getResponse()
->isRedirect('/fr/event/event/' . $event->getId() . '/show'));
->isRedirect('/fr/event/event/'.$event->getId().'/show'));
}
public function testNewActionWrongParameters()
@@ -177,7 +177,7 @@ final class ParticipationControllerTest extends WebTestCase
400,
$this->client->getResponse()->getStatusCode(),
'Test that /fr/event/participation/new fail if '
. 'both person_id and persons_ids are missing'
.'both person_id and persons_ids are missing'
);
// having both person_id and persons_ids
@@ -197,7 +197,7 @@ final class ParticipationControllerTest extends WebTestCase
400,
$this->client->getResponse()->getStatusCode(),
'test that /fr/event/participation/new fail if both person_id and '
. 'persons_ids are set'
.'persons_ids are set'
);
// missing event_id
@@ -285,11 +285,11 @@ final class ParticipationControllerTest extends WebTestCase
$crawler = $this->client->followRedirect();
$span1 = $crawler->filter('table td span.entity-person a:contains("'
. $person1->getFirstName() . '"):contains("' . $person1->getLastname() . '")');
$this->assertGreaterThan(0, count($span1));
.$person1->getFirstName().'"):contains("'.$person1->getLastname().'")');
$this->assertGreaterThan(0, \count($span1));
$span2 = $crawler->filter('table td span.entity-person a:contains("'
. $person2->getFirstName() . '"):contains("' . $person2->getLastname() . '")');
$this->assertGreaterThan(0, count($span2));
.$person2->getFirstName().'"):contains("'.$person2->getLastname().'")');
$this->assertGreaterThan(0, \count($span2));
// as the container has reloaded, reload the event
$event = $this->em->getRepository(\Chill\EventBundle\Entity\Event::class)->find($event->getId());
@@ -338,10 +338,7 @@ final class ParticipationControllerTest extends WebTestCase
$newPerson = $this->getRandomPerson();
// build the `persons_ids` parameter
$persons_ids_string = implode(',', array_merge(
$persons_id,
[$newPerson->getId()]
));
$persons_ids_string = implode(',', [...$persons_id, $newPerson->getId()]);
$crawler = $this->client->request(
'GET',
@@ -360,8 +357,8 @@ final class ParticipationControllerTest extends WebTestCase
// count that the one UL contains the new person string
$firstPerson = $event->getParticipations()->first()->getPerson();
$ul = $crawler->filter('ul:contains("' . $firstPerson->getLastName() . '")'
. ':contains("' . $firstPerson->getFirstName() . '")');
$ul = $crawler->filter('ul:contains("'.$firstPerson->getLastName().'")'
.':contains("'.$firstPerson->getFirstName().'")');
$this->assertEquals(
1,
@@ -434,9 +431,9 @@ final class ParticipationControllerTest extends WebTestCase
$crawler = $this->client->followRedirect();
$span = $crawler->filter('table td span.entity-person a:contains("'
. $person->getFirstName() . '"):contains("' . $person->getLastname() . '")');
.$person->getFirstName().'"):contains("'.$person->getLastname().'")');
$this->assertGreaterThan(0, count($span));
$this->assertGreaterThan(0, \count($span));
// as the container has reloaded, reload the event
$event = $this->em->getRepository(\Chill\EventBundle\Entity\Event::class)->find($event->getId());
@@ -446,7 +443,6 @@ final class ParticipationControllerTest extends WebTestCase
}
/**
*
* @return \Chill\EventBundle\Entity\Event
*/
protected function getRandomEvent(mixed $centerName = 'Center A', mixed $circleName = 'social')
@@ -456,7 +452,7 @@ final class ParticipationControllerTest extends WebTestCase
$circles = $this->em->getRepository(\Chill\MainBundle\Entity\Scope::class)
->findAll();
array_filter($circles, static fn ($circle) => in_array($circleName, $circle->getName(), true));
array_filter($circles, static fn ($circle) => \in_array($circleName, $circle->getName(), true));
$circle = $circles[0];
$events = $this->em->getRepository(\Chill\EventBundle\Entity\Event::class)
@@ -469,7 +465,7 @@ final class ParticipationControllerTest extends WebTestCase
* Return a random event only if he has more than one participation.
*
* @param string $centerName
* @param type $circleName
* @param type $circleName
*
* @return \Chill\EventBundle\Entity\Event
*/
@@ -507,7 +503,7 @@ final class ParticipationControllerTest extends WebTestCase
$person = $persons[array_rand($persons)];
if (in_array($person->getId(), $this->personsIdsCache, true)) {
if (\in_array($person->getId(), $this->personsIdsCache, true)) {
return $this->getRandomPerson($centerName); // we try another time
}
$this->personsIdsCache[] = $person->getId();

View File

@@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
* @internal
*
* @coversNothing
*/
final class RoleControllerTest extends WebTestCase

View File

@@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
* @internal
*
* @coversNothing
*/
final class StatusControllerTest extends WebTestCase

View File

@@ -15,12 +15,12 @@ use Chill\EventBundle\Entity\Event;
use Chill\EventBundle\Search\EventSearch;
use DateTime;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use function in_array;
/**
* Test the EventSearch class.
*
* @internal
*
* @coversNothing
*/
final class EventSearchTest extends WebTestCase
@@ -150,9 +150,9 @@ final class EventSearchTest extends WebTestCase
'q' => '@events date-from:2016-05-30 date-to:2016-06-20',
]);
/** @var DateTime $dateFrom the date from in DateTime */
$dateFrom = DateTime::createFromFormat('Y-m-d', '2016-05-30');
$dateTo = DateTime::createFromFormat('Y-m-d', '2016-06-20');
/** @var \DateTime $dateFrom the date from in DateTime */
$dateFrom = \DateTime::createFromFormat('Y-m-d', '2016-05-30');
$dateTo = \DateTime::createFromFormat('Y-m-d', '2016-06-20');
$dates = $this->iterateOnRowsToFindDate($crawler->filter('tr'));
@@ -164,7 +164,7 @@ final class EventSearchTest extends WebTestCase
// there should not have any other results, but if any other bundle
// add some other event, we go on next pages
if ($crawler->selectLink('Voir tous les résultats')->count() === 0) {
if (0 === $crawler->selectLink('Voir tous les résultats')->count()) {
return;
}
@@ -178,7 +178,7 @@ final class EventSearchTest extends WebTestCase
$this->assertLessThanOrEqual($dateTo, $date);
}
//iterate on pagination
// iterate on pagination
$crawlerAllResults->filter('.pagination a')->each(function ($a, $i) use ($dateFrom) {
$page = $this->client->click($a->link());
$dates = $this->iterateOnRowsToFindDate($page->filter('tr'));
@@ -196,8 +196,8 @@ final class EventSearchTest extends WebTestCase
$crawler = $this->client->request('GET', '/fr/search', [
'q' => '@events date-from:2016-05-30',
]);
/** @var DateTime $dateFrom the date from in DateTime */
$dateFrom = DateTime::createFromFormat('Y-m-d', '2016-05-30');
/** @var \DateTime $dateFrom the date from in DateTime */
$dateFrom = \DateTime::createFromFormat('Y-m-d', '2016-05-30');
$dates = $this->iterateOnRowsToFindDate($crawler->filter('tr'));
@@ -214,7 +214,7 @@ final class EventSearchTest extends WebTestCase
$this->assertGreaterThanOrEqual($dateFrom, $date);
}
//iterate on pagination
// iterate on pagination
$crawlerAllResults->filter('.pagination a')->each(function ($a, $i) use ($dateFrom) {
$page = $this->client->click($a->link());
$dates = $this->iterateOnRowsToFindDate($page->filter('tr'));
@@ -232,8 +232,8 @@ final class EventSearchTest extends WebTestCase
'q' => '@events date:2016-05-30',
]);
/** @var DateTime $dateFrom the date from in DateTime */
$dateTo = DateTime::createFromFormat('Y-m-d', '2016-05-30');
/** @var \DateTime $dateFrom the date from in DateTime */
$dateTo = \DateTime::createFromFormat('Y-m-d', '2016-05-30');
$dates = $this->iterateOnRowsToFindDate($crawler->filter('tr'));
@@ -241,7 +241,7 @@ final class EventSearchTest extends WebTestCase
$this->assertLessThanOrEqual($dateTo, $date);
}
if ($crawler->selectLink('Voir tous les résultats')->count() === 0) {
if (0 === $crawler->selectLink('Voir tous les résultats')->count()) {
return;
}
@@ -254,7 +254,7 @@ final class EventSearchTest extends WebTestCase
$this->assertLessThanOrEqual($dateTo, $date);
}
//iterate on pagination
// iterate on pagination
$crawlerAllResults->filter('.pagination a')->each(function ($a, $i) {
$page = $this->client->click($a->link());
$dates = $this->iterateOnRowsToFindDate($page->filter('tr'));
@@ -307,7 +307,7 @@ final class EventSearchTest extends WebTestCase
{
$event1 = (new Event())
->setCenter($this->centerA)
->setDate(new DateTime('2016-05-30'))
->setDate(new \DateTime('2016-05-30'))
->setName('Printemps européen')
->setType($this->eventType)
->setCircle($this->getCircle());
@@ -316,7 +316,7 @@ final class EventSearchTest extends WebTestCase
$event2 = (new Event())
->setCenter($this->centerA)
->setDate(new DateTime('2016-06-24'))
->setDate(new \DateTime('2016-06-24'))
->setName('Hiver de la droite')
->setType($this->eventType)
->setCircle($this->getCircle());
@@ -338,7 +338,7 @@ final class EventSearchTest extends WebTestCase
/** @var \Chill\MainBundle\Entity\Scope $circle */
foreach ($circles as $circle) {
if (in_array($name, $circle->getName(), true)) {
if (\in_array($name, $circle->getName(), true)) {
return $circle;
}
}
@@ -348,7 +348,7 @@ final class EventSearchTest extends WebTestCase
* this function iterate on row from results of events and return the content
* of the second column (which should contains the date) in DateTime objects.
*
* @return DateTime[]
* @return \DateTime[]
*/
private function iterateOnRowsToFindDate(\Symfony\Component\DomCrawler\Crawler $trs)
{
@@ -375,8 +375,8 @@ final class EventSearchTest extends WebTestCase
// transform the date, which should be in french, into a DateTime object
$parts = explode(' ', (string) $tdDate->text());
return DateTime::createFromFormat('Y-m-d', $parts[2] .
'-' . $months[$parts[1]] . '-' . $parts[0]);
return \DateTime::createFromFormat('Y-m-d', $parts[2].
'-'.$months[$parts[1]].'-'.$parts[0]);
}
});

View File

@@ -20,12 +20,8 @@ use Chill\MainBundle\Timeline\TimelineSingleQuery;
use Chill\PersonBundle\Entity\Person;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\ClassMetadata;
use LogicException;
use RuntimeException;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use function count;
/**
* Class TimelineEventProvider.
*/
@@ -58,7 +54,7 @@ class TimelineEventProvider implements TimelineProviderInterface
$this->helper = $helper;
if (!$storage->getToken()->getUser() instanceof User) {
throw new RuntimeException('A user should be authenticated !');
throw new \RuntimeException('A user should be authenticated !');
}
$this->user = $storage->getToken()->getUser();
}
@@ -66,9 +62,9 @@ class TimelineEventProvider implements TimelineProviderInterface
/**
* @param string $context
*
* @throws \Doctrine\ORM\Mapping\MappingException
*
* @return array|string[]
*
* @throws \Doctrine\ORM\Mapping\MappingException
*/
public function fetchQuery($context, array $args)
{
@@ -79,9 +75,9 @@ class TimelineEventProvider implements TimelineProviderInterface
$metadataPerson = $this->em->getClassMetadata('ChillPersonBundle:Person');
return TimelineSingleQuery::fromArray([
'id' => $metadataEvent->getTableName() . '.' . $metadataEvent->getColumnName('id'),
'id' => $metadataEvent->getTableName().'.'.$metadataEvent->getColumnName('id'),
'type' => 'event',
'date' => $metadataEvent->getTableName() . '.' . $metadataEvent->getColumnName('date'),
'date' => $metadataEvent->getTableName().'.'.$metadataEvent->getColumnName('date'),
'FROM' => $this->getFromClause($metadataEvent, $metadataParticipation, $metadataPerson),
'WHERE' => $this->getWhereClause($metadataEvent, $metadataParticipation, $metadataPerson, $args['person']),
'parameters' => [],
@@ -106,7 +102,7 @@ class TimelineEventProvider implements TimelineProviderInterface
}
/**
* @param Event $entity
* @param Event $entity
* @param string $context
*
* @return array|mixed[]
@@ -140,20 +136,19 @@ class TimelineEventProvider implements TimelineProviderInterface
*
* @param string $context
*
* @throws LogicException if the context is not supported
* @throws \LogicException if the context is not supported
*/
private function checkContext($context)
{
if ('person' !== $context) {
throw new LogicException("The context '{$context}' is not "
. "supported. Currently only 'person' is supported");
throw new \LogicException("The context '{$context}' is not supported. Currently only 'person' is supported");
}
}
/**
* @throws \Doctrine\ORM\Mapping\MappingException
*
* @return string
*
* @throws \Doctrine\ORM\Mapping\MappingException
*/
private function getFromClause(
ClassMetadata $metadataEvent,
@@ -164,23 +159,23 @@ class TimelineEventProvider implements TimelineProviderInterface
$participationPersonMapping = $metadataParticipation->getAssociationMapping('person');
return $metadataEvent->getTableName()
. ' JOIN ' . $metadataParticipation->getTableName()
. ' ON ' . $metadataParticipation->getTableName()
. '.' . $eventParticipationMapping['joinColumns'][0]['name']
. ' = ' . $metadataEvent->getTableName()
. '.' . $eventParticipationMapping['joinColumns'][0]['referencedColumnName']
.' JOIN '.$metadataParticipation->getTableName()
.' ON '.$metadataParticipation->getTableName()
.'.'.$eventParticipationMapping['joinColumns'][0]['name']
.' = '.$metadataEvent->getTableName()
.'.'.$eventParticipationMapping['joinColumns'][0]['referencedColumnName']
. ' JOIN ' . $metadataPerson->getTableName()
. ' ON ' . $metadataPerson->getTableName()
. '.' . $participationPersonMapping['joinColumns'][0]['referencedColumnName']
. ' = ' . $metadataParticipation->getTableName()
. '.' . $participationPersonMapping['joinColumns'][0]['name'];
.' JOIN '.$metadataPerson->getTableName()
.' ON '.$metadataPerson->getTableName()
.'.'.$participationPersonMapping['joinColumns'][0]['referencedColumnName']
.' = '.$metadataParticipation->getTableName()
.'.'.$participationPersonMapping['joinColumns'][0]['name'];
}
/**
* @throws \Doctrine\ORM\Mapping\MappingException
*
* @return string
*
* @throws \Doctrine\ORM\Mapping\MappingException
*/
private function getWhereClause(
ClassMetadata $metadataEvent,
@@ -193,7 +188,7 @@ class TimelineEventProvider implements TimelineProviderInterface
$reachableCenters = $this->helper->getReachableCenters($this->user, $role);
$associationMapping = $metadataParticipation->getAssociationMapping('person');
if (count($reachableCenters) === 0) {
if (0 === \count($reachableCenters)) {
return 'FALSE = TRUE';
}
@@ -213,15 +208,15 @@ class TimelineEventProvider implements TimelineProviderInterface
);
$centerAndScopeLines[] = sprintf(
'(%s = %d AND %s IN (%s))',
$metadataPerson->getTableName() . '.' .
$metadataPerson->getTableName().'.'.
$metadataPerson->getAssociationMapping('center')['joinColumns'][0]['name'],
$center->getId(),
$metadataEvent->getTableName() . '.' .
$metadataEvent->getTableName().'.'.
$metadataEvent->getAssociationMapping('circle')['joinColumns'][0]['name'],
implode(',', $reachableCircleId)
);
}
$whereClause .= ' AND (' . implode(' OR ', $centerAndScopeLines) . ')';
$whereClause .= ' AND ('.implode(' OR ', $centerAndScopeLines).')';
return $whereClause;
}

View File

@@ -22,7 +22,7 @@ class Version20160318111334 extends AbstractMigration
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE chill_event_role DROP CONSTRAINT FK_AA714E54C54C8C93');
$this->addSql('ALTER TABLE chill_event_status DROP CONSTRAINT FK_A6CC85D0C54C8C93');
@@ -51,7 +51,7 @@ class Version20160318111334 extends AbstractMigration
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SEQUENCE chill_event_event_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE chill_event_role_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
@@ -59,37 +59,37 @@ class Version20160318111334 extends AbstractMigration
$this->addSql('CREATE SEQUENCE chill_event_event_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE chill_event_participation_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_event_event_type ('
. 'id INT NOT NULL, name JSON NOT NULL, '
. 'active BOOLEAN NOT NULL, PRIMARY KEY(id))');
.'id INT NOT NULL, name JSON NOT NULL, '
.'active BOOLEAN NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE chill_event_role ('
. 'id INT NOT NULL, '
. 'type_id INT DEFAULT NULL, '
. 'name JSON NOT NULL, '
. 'active BOOLEAN NOT NULL, '
. 'PRIMARY KEY(id))');
.'id INT NOT NULL, '
.'type_id INT DEFAULT NULL, '
.'name JSON NOT NULL, '
.'active BOOLEAN NOT NULL, '
.'PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_AA714E54C54C8C93 ON chill_event_role (type_id)');
$this->addSql('CREATE TABLE chill_event_status (id INT NOT NULL, '
. 'type_id INT DEFAULT NULL, '
. 'name JSON NOT NULL, '
. 'active BOOLEAN NOT NULL, '
. 'PRIMARY KEY(id))');
.'type_id INT DEFAULT NULL, '
.'name JSON NOT NULL, '
.'active BOOLEAN NOT NULL, '
.'PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_A6CC85D0C54C8C93 ON chill_event_status (type_id)');
$this->addSql('CREATE TABLE chill_event_event ('
. 'id INT NOT NULL, '
. 'name VARCHAR(150) NOT NULL, '
. 'date DATE NOT NULL, '
. 'center_id INT DEFAULT NULL, '
. 'type_id INT DEFAULT NULL, '
. 'circle_id INT DEFAULT NULL, '
. 'PRIMARY KEY(id))');
.'id INT NOT NULL, '
.'name VARCHAR(150) NOT NULL, '
.'date DATE NOT NULL, '
.'center_id INT DEFAULT NULL, '
.'type_id INT DEFAULT NULL, '
.'circle_id INT DEFAULT NULL, '
.'PRIMARY KEY(id))');
$this->addSql('CREATE TABLE chill_event_participation ('
. 'id INT NOT NULL, '
. 'event_id INT DEFAULT NULL, '
. 'person_id INT DEFAULT NULL, '
. 'role_id INT DEFAULT NULL, '
. 'status_id INT DEFAULT NULL, '
. 'lastUpdate TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, '
. 'PRIMARY KEY(id))');
.'id INT NOT NULL, '
.'event_id INT DEFAULT NULL, '
.'person_id INT DEFAULT NULL, '
.'role_id INT DEFAULT NULL, '
.'status_id INT DEFAULT NULL, '
.'lastUpdate TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, '
.'PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_4E7768AC71F7E88B ON chill_event_participation (event_id)');
$this->addSql('CREATE INDEX IDX_4E7768AC217BBB47 ON chill_event_participation (person_id)');
$this->addSql('CREATE INDEX IDX_4E7768ACD60322AC ON chill_event_participation (role_id)');
@@ -99,44 +99,44 @@ class Version20160318111334 extends AbstractMigration
$this->addSql('CREATE INDEX IDX_FA320FC870EE2FF6 ON chill_event_event (circle_id)');
$this->addSql('ALTER TABLE chill_event_event '
. 'ADD CONSTRAINT FK_FA320FC85932F377 FOREIGN KEY (center_id) '
. 'REFERENCES centers (id) '
. 'NOT DEFERRABLE INITIALLY IMMEDIATE');
.'ADD CONSTRAINT FK_FA320FC85932F377 FOREIGN KEY (center_id) '
.'REFERENCES centers (id) '
.'NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_event_event '
. 'ADD CONSTRAINT FK_FA320FC870EE2FF6 FOREIGN KEY (circle_id) '
. 'REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
.'ADD CONSTRAINT FK_FA320FC870EE2FF6 FOREIGN KEY (circle_id) '
.'REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_event_event '
. 'ADD CONSTRAINT FK_FA320FC8C54C8C93 FOREIGN KEY (type_id) '
. 'REFERENCES chill_event_event_type (id) '
. 'NOT DEFERRABLE INITIALLY IMMEDIATE');
.'ADD CONSTRAINT FK_FA320FC8C54C8C93 FOREIGN KEY (type_id) '
.'REFERENCES chill_event_event_type (id) '
.'NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_event_role '
. 'ADD CONSTRAINT FK_AA714E54C54C8C93 FOREIGN KEY (type_id) '
. 'REFERENCES chill_event_event_type (id) '
. 'NOT DEFERRABLE INITIALLY IMMEDIATE');
.'ADD CONSTRAINT FK_AA714E54C54C8C93 FOREIGN KEY (type_id) '
.'REFERENCES chill_event_event_type (id) '
.'NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_event_status '
. 'ADD CONSTRAINT FK_A6CC85D0C54C8C93 '
. 'FOREIGN KEY (type_id) '
. 'REFERENCES chill_event_event_type (id) '
. 'NOT DEFERRABLE INITIALLY IMMEDIATE');
.'ADD CONSTRAINT FK_A6CC85D0C54C8C93 '
.'FOREIGN KEY (type_id) '
.'REFERENCES chill_event_event_type (id) '
.'NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_event_participation '
. 'ADD CONSTRAINT FK_4E7768AC71F7E88B '
. 'FOREIGN KEY (event_id) '
. 'REFERENCES chill_event_event (id) '
. 'NOT DEFERRABLE INITIALLY IMMEDIATE');
.'ADD CONSTRAINT FK_4E7768AC71F7E88B '
.'FOREIGN KEY (event_id) '
.'REFERENCES chill_event_event (id) '
.'NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_event_participation '
. 'ADD CONSTRAINT FK_4E7768AC217BBB47 '
. 'FOREIGN KEY (person_id) '
. 'REFERENCES Person (id) '
. 'NOT DEFERRABLE INITIALLY IMMEDIATE');
.'ADD CONSTRAINT FK_4E7768AC217BBB47 '
.'FOREIGN KEY (person_id) '
.'REFERENCES Person (id) '
.'NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_event_participation '
. 'ADD CONSTRAINT FK_4E7768ACD60322AC '
. 'FOREIGN KEY (role_id) '
. 'REFERENCES chill_event_role (id) '
. 'NOT DEFERRABLE INITIALLY IMMEDIATE');
.'ADD CONSTRAINT FK_4E7768ACD60322AC '
.'FOREIGN KEY (role_id) '
.'REFERENCES chill_event_role (id) '
.'NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_event_participation '
. 'ADD CONSTRAINT FK_4E7768AC6BF700BD '
. 'FOREIGN KEY (status_id) '
. 'REFERENCES chill_event_status (id) '
. 'NOT DEFERRABLE INITIALLY IMMEDIATE');
.'ADD CONSTRAINT FK_4E7768AC6BF700BD '
.'FOREIGN KEY (status_id) '
.'REFERENCES chill_event_status (id) '
.'NOT DEFERRABLE INITIALLY IMMEDIATE');
}
}

View File

@@ -21,7 +21,7 @@ final class Version20190110140538 extends AbstractMigration
{
public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE chill_event_event ALTER date TYPE DATE');
$this->addSql('ALTER TABLE chill_event_event ALTER date DROP DEFAULT');
@@ -29,7 +29,7 @@ final class Version20190110140538 extends AbstractMigration
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE chill_event_event ALTER date TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
$this->addSql('ALTER TABLE chill_event_event ALTER date DROP DEFAULT');

View File

@@ -22,7 +22,7 @@ final class Version20190115140042 extends AbstractMigration
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE chill_event_event DROP CONSTRAINT FK_FA320FC8D0AFA354');
$this->addSql('DROP INDEX IDX_FA320FC8D0AFA354');
@@ -32,7 +32,7 @@ final class Version20190115140042 extends AbstractMigration
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE chill_event_event ADD moderator_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_event_event ADD CONSTRAINT FK_FA320FC8D0AFA354 FOREIGN KEY (moderator_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');

View File

@@ -22,7 +22,7 @@ final class Version20190201143121 extends AbstractMigration
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE chill_event_event DROP CONSTRAINT fk_fa320fc8d0afa354');
$this->addSql('ALTER TABLE chill_event_event ADD CONSTRAINT fk_fa320fc8d0afa354 FOREIGN KEY (moderator_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
@@ -31,7 +31,7 @@ final class Version20190201143121 extends AbstractMigration
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE chill_event_event DROP CONSTRAINT FK_FA320FC8D0AFA354');
$this->addSql('ALTER TABLE chill_event_event ADD CONSTRAINT FK_FA320FC8D0AFA354 FOREIGN KEY (moderator_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');