php cs fixes

This commit is contained in:
Julie Lenaerts 2023-11-09 19:25:41 +01:00
parent 6d608ab35a
commit 32a103d86a
9 changed files with 48 additions and 56 deletions

View File

@ -1,22 +1,24 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Controller; namespace Chill\MainBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Chill\MainBundle\Entity\NewsItem;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Pagination\PaginatorInterface;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security;
class DashboardApiController class DashboardApiController
{ {
/** /**
* Get user dashboard config (not yet based on user id and still hardcoded for now) * Get user dashboard config (not yet based on user id and still hardcoded for now).
* *
* @Route("/api/1.0/main/dashboard-config-item.json", methods={"get"}) * @Route("/api/1.0/main/dashboard-config-item.json", methods={"get"})
*/ */
@ -30,11 +32,10 @@ class DashboardApiController
'metadata' => [ 'metadata' => [
// arbitrary data that will be store "some time" // arbitrary data that will be store "some time"
'only_unread' => false, 'only_unread' => false,
] ],
] ],
]; ];
return new JsonResponse($data, JsonResponse::HTTP_OK, []); return new JsonResponse($data, JsonResponse::HTTP_OK, []);
} }
} }

View File

@ -11,17 +11,11 @@ declare(strict_types=1);
namespace Chill\MainBundle\Controller; namespace Chill\MainBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Chill\MainBundle\Entity\NewsItem;
use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Pagination\PaginatorInterface;
use Chill\MainBundle\Repository\NewsItemRepository; use Chill\MainBundle\Repository\NewsItemRepository;
use Chill\MainBundle\Serializer\Model\Collection; use Chill\MainBundle\Serializer\Model\Collection;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Chill\MainBundle\Serializer\NewsItemNormalizer;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\SerializerInterface;
@ -30,10 +24,11 @@ class NewsItemApiController
public function __construct( public function __construct(
private NewsItemRepository $newsItemRepository, private NewsItemRepository $newsItemRepository,
private SerializerInterface $serializer, private SerializerInterface $serializer,
private PaginatorFactory $paginatorFactory) {} private PaginatorFactory $paginatorFactory
) {}
/** /**
* Get list of news items filtered on start and end date * Get list of news items filtered on start and end date.
* *
* @Route("/api/1.0/main/news.json", methods={"get"}) * @Route("/api/1.0/main/news.json", methods={"get"})
*/ */
@ -50,6 +45,5 @@ class NewsItemApiController
AbstractNormalizer::GROUPS => ['read'], AbstractNormalizer::GROUPS => ['read'],
] ]
), JsonResponse::HTTP_OK, [], true); ), JsonResponse::HTTP_OK, [], true);
} }
} }

View File

@ -19,7 +19,6 @@ use Chill\MainBundle\Controller\CountryController;
use Chill\MainBundle\Controller\LanguageController; use Chill\MainBundle\Controller\LanguageController;
use Chill\MainBundle\Controller\LocationController; use Chill\MainBundle\Controller\LocationController;
use Chill\MainBundle\Controller\LocationTypeController; use Chill\MainBundle\Controller\LocationTypeController;
use Chill\MainBundle\Controller\NewsItemApiController;
use Chill\MainBundle\Controller\NewsItemController; use Chill\MainBundle\Controller\NewsItemController;
use Chill\MainBundle\Controller\RegroupmentController; use Chill\MainBundle\Controller\RegroupmentController;
use Chill\MainBundle\Controller\UserController; use Chill\MainBundle\Controller\UserController;

View File

@ -1,12 +1,20 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Entity; namespace Chill\MainBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer; use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
* @ORM\Entity * @ORM\Entity
* *
@ -49,11 +57,9 @@ class DashboardConfigItem
private User $user; private User $user;
/** /**
*
* @ORM\Column(type="json") * @ORM\Column(type="json")
* *
* @Serializer\Groups({"dashboardConfigItem:read"}) * @Serializer\Groups({"dashboardConfigItem:read"})
*
*/ */
private array $metadata = []; private array $metadata = [];

View File

@ -187,5 +187,4 @@ class NewsItem implements TrackCreationInterface, TrackUpdateInterface
{ {
return $this->id; return $this->id;
} }
} }

View File

@ -18,7 +18,6 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\Translation\TranslatorInterface;
class NewsItemType extends AbstractType class NewsItemType extends AbstractType
{ {
@ -36,12 +35,12 @@ class NewsItemType extends AbstractType
ChillDateType::class, ChillDateType::class,
[ [
'required' => true, 'required' => true,
'input' => 'datetime_immutable' 'input' => 'datetime_immutable',
] ]
) )
->add('endDate', ChillDateType::class, [ ->add('endDate', ChillDateType::class, [
'required' => false, 'required' => false,
'input' => 'datetime_immutable' 'input' => 'datetime_immutable',
]); ]);
} }

View File

@ -1,5 +1,14 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Repository; namespace Chill\MainBundle\Repository;
use Chill\MainBundle\Entity\NewsItem; use Chill\MainBundle\Entity\NewsItem;
@ -7,11 +16,9 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ObjectRepository; use Doctrine\Persistence\ObjectRepository;
use Faker\Core\DateTime;
class NewsItemRepository implements ObjectRepository class NewsItemRepository implements ObjectRepository
{ {
private readonly EntityRepository $repository; private readonly EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager) public function __construct(EntityManagerInterface $entityManager)
@ -24,40 +31,26 @@ class NewsItemRepository implements ObjectRepository
return $this->repository->createQueryBuilder($alias, $indexBy); return $this->repository->createQueryBuilder($alias, $indexBy);
} }
/**
* @inheritDoc
*/
public function find($id) public function find($id)
{ {
return $this->repository->find($id); return $this->repository->find($id);
} }
/**
* @inheritDoc
*/
public function findAll() public function findAll()
{ {
return $this->repository->findAll(); return $this->repository->findAll();
} }
/** public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null)
* @inheritDoc
*/
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null)
{ {
return $this->repository->findBy($criteria, $orderBy, $limit, $offset); return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
} }
/**
* @inheritDoc
*/
public function findOneBy(array $criteria) public function findOneBy(array $criteria)
{ {
return $this->repository->findOneBy($criteria); return $this->repository->findOneBy($criteria);
} }
/**
* @inheritDoc
*/
public function getClassName() public function getClassName()
{ {
return NewsItem::class; return NewsItem::class;

View File

@ -11,13 +11,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\Serializer\Normalizer; namespace Chill\MainBundle\Serializer\Normalizer;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\DashboardItem;
use Chill\MainBundle\Entity\NewsItem; use Chill\MainBundle\Entity\NewsItem;
use Chill\MainBundle\Repository\CenterRepository;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class NewsItemNormalizer implements NormalizerInterface class NewsItemNormalizer implements NormalizerInterface
@ -30,7 +24,7 @@ class NewsItemNormalizer implements NormalizerInterface
'title' => $newsItem->getTitle(), 'title' => $newsItem->getTitle(),
'content' => $newsItem->getContent(), 'content' => $newsItem->getContent(),
'startdate' => $newsItem->getStartDate(), 'startdate' => $newsItem->getStartDate(),
'enddate' => $newsItem->getEndDate() 'enddate' => $newsItem->getEndDate(),
]; ];
} }

View File

@ -2,13 +2,20 @@
declare(strict_types=1); declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\Migrations\Main; namespace Chill\Migrations\Main;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/** /**
* Create dashboard config item and news item * Create dashboard config item and news item.
*/ */
final class Version20231108141141 extends AbstractMigration final class Version20231108141141 extends AbstractMigration
{ {