mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 14:25:00 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -15,7 +15,6 @@ use Chill\CalendarBundle\Repository\CalendarRepository;
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -40,8 +39,8 @@ class CalendarAPIController extends ApiController
|
||||
throw new BadRequestHttpException('You must provide a dateFrom parameter');
|
||||
}
|
||||
|
||||
if (false === $dateFrom = DateTimeImmutable::createFromFormat(
|
||||
DateTimeImmutable::ATOM,
|
||||
if (false === $dateFrom = \DateTimeImmutable::createFromFormat(
|
||||
\DateTimeImmutable::ATOM,
|
||||
$request->query->get('dateFrom')
|
||||
)) {
|
||||
throw new BadRequestHttpException('dateFrom not parsable');
|
||||
@@ -51,8 +50,8 @@ class CalendarAPIController extends ApiController
|
||||
throw new BadRequestHttpException('You must provide a dateTo parameter');
|
||||
}
|
||||
|
||||
if (false === $dateTo = DateTimeImmutable::createFromFormat(
|
||||
DateTimeImmutable::ATOM,
|
||||
if (false === $dateTo = \DateTimeImmutable::createFromFormat(
|
||||
\DateTimeImmutable::ATOM,
|
||||
$request->query->get('dateTo')
|
||||
)) {
|
||||
throw new BadRequestHttpException('dateTo not parsable');
|
||||
|
@@ -30,11 +30,8 @@ use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use DateTimeImmutable;
|
||||
use Exception;
|
||||
use http\Exception\UnexpectedValueException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use RuntimeException;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Form;
|
||||
@@ -82,12 +79,12 @@ class CalendarController extends AbstractController
|
||||
$view = '@ChillCalendar/Calendar/confirm_deleteByPerson.html.twig';
|
||||
$redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_person', ['id' => $person->getId()]);
|
||||
} else {
|
||||
throw new RuntimeException('nor person or accompanying period');
|
||||
throw new \RuntimeException('nor person or accompanying period');
|
||||
}
|
||||
|
||||
$form = $this->createDeleteForm($entity);
|
||||
|
||||
if ($request->getMethod() === Request::METHOD_DELETE) {
|
||||
if (Request::METHOD_DELETE === $request->getMethod()) {
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
@@ -138,7 +135,7 @@ class CalendarController extends AbstractController
|
||||
$view = '@ChillCalendar/Calendar/editByPerson.html.twig';
|
||||
$redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_person', ['id' => $person->getId()]);
|
||||
} else {
|
||||
throw new RuntimeException('no person nor accompanying period');
|
||||
throw new \RuntimeException('no person nor accompanying period');
|
||||
}
|
||||
|
||||
$form = $this->createForm(CalendarType::class, $entity)
|
||||
@@ -148,7 +145,7 @@ class CalendarController extends AbstractController
|
||||
$templates = $this->docGeneratorTemplateRepository->findByEntity(Calendar::class);
|
||||
|
||||
foreach ($templates as $template) {
|
||||
$form->add('save_and_generate_doc_' . $template->getId(), SubmitType::class, [
|
||||
$form->add('save_and_generate_doc_'.$template->getId(), SubmitType::class, [
|
||||
'label' => $this->translatableStringHelper->localize($template->getName()),
|
||||
]);
|
||||
}
|
||||
@@ -165,7 +162,7 @@ class CalendarController extends AbstractController
|
||||
}
|
||||
|
||||
foreach ($templates as $template) {
|
||||
if ($form->get('save_and_generate_doc_' . $template->getId())->isClicked()) {
|
||||
if ($form->get('save_and_generate_doc_'.$template->getId())->isClicked()) {
|
||||
return $this->redirectToRoute('chill_docgenerator_generate_from_template', [
|
||||
'entityClassName' => Calendar::class,
|
||||
'entityId' => $entity->getId(),
|
||||
@@ -327,7 +324,7 @@ class CalendarController extends AbstractController
|
||||
$form->add('save_and_upload_doc', SubmitType::class);
|
||||
|
||||
foreach ($templates as $template) {
|
||||
$form->add('save_and_generate_doc_' . $template->getId(), SubmitType::class, [
|
||||
$form->add('save_and_generate_doc_'.$template->getId(), SubmitType::class, [
|
||||
'label' => $this->translatableStringHelper->localize($template->getName()),
|
||||
]);
|
||||
}
|
||||
@@ -342,12 +339,12 @@ class CalendarController extends AbstractController
|
||||
|
||||
if ($form->get('save_and_upload_doc')->isClicked()) {
|
||||
return $this->redirectToRoute('chill_calendar_calendardoc_new', [
|
||||
'id' => $entity->getId()
|
||||
'id' => $entity->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($templates as $template) {
|
||||
if ($form->get('save_and_generate_doc_' . $template->getId())->isClicked()) {
|
||||
if ($form->get('save_and_generate_doc_'.$template->getId())->isClicked()) {
|
||||
return $this->redirectToRoute('chill_docgenerator_generate_from_template', [
|
||||
'entityClassName' => Calendar::class,
|
||||
'entityId' => $entity->getId(),
|
||||
@@ -392,7 +389,7 @@ class CalendarController extends AbstractController
|
||||
*/
|
||||
public function showAction(Request $request, int $id): Response
|
||||
{
|
||||
throw new Exception('not implemented');
|
||||
throw new \Exception('not implemented');
|
||||
$view = null;
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
@@ -453,7 +450,7 @@ class CalendarController extends AbstractController
|
||||
'entity' => $entity,
|
||||
'user' => $user,
|
||||
'activityData' => $activityData,
|
||||
//'delete_form' => $deleteForm->createView(),
|
||||
// 'delete_form' => $deleteForm->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -498,12 +495,12 @@ class CalendarController extends AbstractController
|
||||
'returnPath' => $request->query->get('returnPath', null),
|
||||
];
|
||||
|
||||
if ($calendar->getContext() === 'accompanying_period') {
|
||||
if ('accompanying_period' === $calendar->getContext()) {
|
||||
$routeParams['accompanying_period_id'] = $calendar->getAccompanyingPeriod()->getId();
|
||||
} elseif ($calendar->getContext() === 'person') {
|
||||
} elseif ('person' === $calendar->getContext()) {
|
||||
$routeParams['person_id'] = $calendar->getPerson()->getId();
|
||||
} else {
|
||||
throw new RuntimeException('context not found for this calendar');
|
||||
throw new \RuntimeException('context not found for this calendar');
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('chill_activity_activity_new', $routeParams);
|
||||
@@ -512,7 +509,7 @@ class CalendarController extends AbstractController
|
||||
private function buildListFilterOrder(): FilterOrderHelper
|
||||
{
|
||||
$filterOrder = $this->filterOrderHelperFactory->create(self::class);
|
||||
$filterOrder->addDateRange('startDate', null, new DateTimeImmutable('3 days ago'), null);
|
||||
$filterOrder->addDateRange('startDate', null, new \DateTimeImmutable('3 days ago'), null);
|
||||
|
||||
return $filterOrder->build();
|
||||
}
|
||||
|
@@ -16,7 +16,6 @@ use Chill\CalendarBundle\Entity\CalendarDoc;
|
||||
use Chill\CalendarBundle\Form\CalendarDocCreateType;
|
||||
use Chill\CalendarBundle\Form\CalendarDocEditType;
|
||||
use Chill\CalendarBundle\Security\Voter\CalendarDocVoter;
|
||||
use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
@@ -27,9 +26,6 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use UnexpectedValueException;
|
||||
|
||||
final readonly class CalendarDocController
|
||||
{
|
||||
@@ -69,7 +65,7 @@ final readonly class CalendarDocController
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException('Unsupported context');
|
||||
throw new \UnexpectedValueException('Unsupported context');
|
||||
}
|
||||
|
||||
$calendarDocDTO = new CalendarDoc\CalendarDocCreateDTO();
|
||||
@@ -186,7 +182,7 @@ final readonly class CalendarDocController
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException('Unsupported context');
|
||||
throw new \UnexpectedValueException('Unsupported context');
|
||||
}
|
||||
|
||||
$calendarDocEditDTO = new CalendarDoc\CalendarDocEditDTO($calendarDoc);
|
||||
|
@@ -15,12 +15,10 @@ use Chill\CalendarBundle\Repository\CalendarRangeRepository;
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class CalendarRangeAPIController extends ApiController
|
||||
@@ -35,15 +33,15 @@ class CalendarRangeAPIController extends ApiController
|
||||
*/
|
||||
public function availableRanges(User $user, Request $request, string $_format): JsonResponse
|
||||
{
|
||||
//return new JsonResponse(['ok' => true], 200, [], false);
|
||||
// return new JsonResponse(['ok' => true], 200, [], false);
|
||||
$this->denyAccessUnlessGranted('ROLE_USER');
|
||||
|
||||
if (!$request->query->has('dateFrom')) {
|
||||
throw new BadRequestHttpException('You must provide a dateFrom parameter');
|
||||
}
|
||||
|
||||
if (false === $dateFrom = DateTimeImmutable::createFromFormat(
|
||||
DateTimeImmutable::ATOM,
|
||||
if (false === $dateFrom = \DateTimeImmutable::createFromFormat(
|
||||
\DateTimeImmutable::ATOM,
|
||||
$request->query->get('dateFrom')
|
||||
)) {
|
||||
throw new BadRequestHttpException('dateFrom not parsable');
|
||||
@@ -53,8 +51,8 @@ class CalendarRangeAPIController extends ApiController
|
||||
throw new BadRequestHttpException('You must provide a dateTo parameter');
|
||||
}
|
||||
|
||||
if (false === $dateTo = DateTimeImmutable::createFromFormat(
|
||||
DateTimeImmutable::ATOM,
|
||||
if (false === $dateTo = \DateTimeImmutable::createFromFormat(
|
||||
\DateTimeImmutable::ATOM,
|
||||
$request->query->get('dateTo')
|
||||
)) {
|
||||
throw new BadRequestHttpException('dateTo not parsable');
|
||||
|
@@ -31,7 +31,6 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use function in_array;
|
||||
|
||||
class InviteApiController
|
||||
{
|
||||
@@ -58,7 +57,7 @@ class InviteApiController
|
||||
throw new AccessDeniedHttpException('not allowed to answer on this invitation');
|
||||
}
|
||||
|
||||
if (!in_array($answer, Invite::STATUSES, true)) {
|
||||
if (!\in_array($answer, Invite::STATUSES, true)) {
|
||||
throw new BadRequestHttpException('answer not valid');
|
||||
}
|
||||
|
||||
|
@@ -19,13 +19,11 @@ declare(strict_types=1);
|
||||
namespace Chill\CalendarBundle\Controller;
|
||||
|
||||
use Chill\CalendarBundle\Messenger\Message\MSGraphChangeNotificationMessage;
|
||||
use JsonException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use const JSON_THROW_ON_ERROR;
|
||||
|
||||
class RemoteCalendarMSGraphSyncController
|
||||
{
|
||||
@@ -44,8 +42,8 @@ class RemoteCalendarMSGraphSyncController
|
||||
}
|
||||
|
||||
try {
|
||||
$body = json_decode($request->getContent(), true, 512, JSON_THROW_ON_ERROR);
|
||||
} catch (JsonException $e) {
|
||||
$body = json_decode($request->getContent(), true, 512, \JSON_THROW_ON_ERROR);
|
||||
} catch (\JsonException $e) {
|
||||
throw new BadRequestHttpException('could not decode json', $e);
|
||||
}
|
||||
|
||||
|
@@ -22,14 +22,12 @@ use Chill\CalendarBundle\RemoteCalendar\Connector\RemoteCalendarConnectorInterfa
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Contains method to get events (Calendar) from remote calendar.
|
||||
@@ -47,8 +45,8 @@ class RemoteCalendarProxyController
|
||||
throw new BadRequestHttpException('You must provide a dateFrom parameter');
|
||||
}
|
||||
|
||||
if (false === $dateFrom = DateTimeImmutable::createFromFormat(
|
||||
DateTimeImmutable::ATOM,
|
||||
if (false === $dateFrom = \DateTimeImmutable::createFromFormat(
|
||||
\DateTimeImmutable::ATOM,
|
||||
$request->query->get('dateFrom')
|
||||
)) {
|
||||
throw new BadRequestHttpException('dateFrom not parsable');
|
||||
@@ -58,8 +56,8 @@ class RemoteCalendarProxyController
|
||||
throw new BadRequestHttpException('You must provide a dateTo parameter');
|
||||
}
|
||||
|
||||
if (false === $dateTo = DateTimeImmutable::createFromFormat(
|
||||
DateTimeImmutable::ATOM,
|
||||
if (false === $dateTo = \DateTimeImmutable::createFromFormat(
|
||||
\DateTimeImmutable::ATOM,
|
||||
$request->query->get('dateTo')
|
||||
)) {
|
||||
throw new BadRequestHttpException('dateTo not parsable');
|
||||
@@ -87,8 +85,8 @@ class RemoteCalendarProxyController
|
||||
|
||||
// in some case, we cannot paginate: we have to fetch all the items at once. We must avoid
|
||||
// further requests by forcing the number of items returned.
|
||||
if (count($events) > $paginator->getItemsPerPage()) {
|
||||
$paginator->setItemsPerPage(count($events));
|
||||
if (\count($events) > $paginator->getItemsPerPage()) {
|
||||
$paginator->setItemsPerPage(\count($events));
|
||||
}
|
||||
|
||||
$collection = new Collection($events, $paginator);
|
||||
|
Reference in New Issue
Block a user