php cs fixes

This commit is contained in:
Julie Lenaerts 2023-11-09 19:25:41 +01:00
parent d6641f70c9
commit d828a6b9e0
11 changed files with 51 additions and 59 deletions

View File

@ -673,8 +673,8 @@ final class ActivityController extends AbstractController
throw $this->createNotFoundException('Accompanying Period not found');
}
// TODO Add permission
// $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
// TODO Add permission
// $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
} else {
throw $this->createNotFoundException('Person or Accompanying Period not found');
}

View File

@ -1,22 +1,24 @@
<?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;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Chill\MainBundle\Entity\NewsItem;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Pagination\PaginatorInterface;
use Doctrine\ORM\EntityManagerInterface;
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\Security\Core\Security;
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"})
*/
@ -30,11 +32,10 @@ class DashboardApiController
'metadata' => [
// arbitrary data that will be store "some time"
'only_unread' => false,
]
]
],
],
];
return new JsonResponse($data, JsonResponse::HTTP_OK, []);
}
}

View File

@ -11,17 +11,11 @@ declare(strict_types=1);
namespace Chill\MainBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Chill\MainBundle\Entity\NewsItem;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Pagination\PaginatorInterface;
use Chill\MainBundle\Repository\NewsItemRepository;
use Chill\MainBundle\Serializer\Model\Collection;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Chill\MainBundle\Serializer\NewsItemNormalizer;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\SerializerInterface;
@ -30,14 +24,15 @@ class NewsItemApiController
public function __construct(
private NewsItemRepository $newsItemRepository,
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"})
*/
public function listCurrentNewsItems():JsonResponse
public function listCurrentNewsItems(): JsonResponse
{
$total = $this->newsItemRepository->countWithDateFilter();
$paginator = $this->paginatorFactory->create($total);
@ -50,6 +45,5 @@ class NewsItemApiController
AbstractNormalizer::GROUPS => ['read'],
]
), JsonResponse::HTTP_OK, [], true);
}
}

View File

@ -19,7 +19,6 @@ use Chill\MainBundle\Controller\CountryController;
use Chill\MainBundle\Controller\LanguageController;
use Chill\MainBundle\Controller\LocationController;
use Chill\MainBundle\Controller\LocationTypeController;
use Chill\MainBundle\Controller\NewsItemApiController;
use Chill\MainBundle\Controller\NewsItemController;
use Chill\MainBundle\Controller\RegroupmentController;
use Chill\MainBundle\Controller\UserController;
@ -792,7 +791,7 @@ class ChillMainExtension extends Extension implements
],
],
],
/* [
/* [
'class' => \Chill\MainBundle\Entity\DashboardConfigItem::class,
'controller' => \Chill\MainBundle\Controller\DashboardApiController::class,
'name' => 'dashboard-config-item',

View File

@ -1,12 +1,20 @@
<?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;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
*
@ -49,11 +57,9 @@ class DashboardConfigItem
private User $user;
/**
*
* @ORM\Column(type="json")
*
* @Serializer\Groups({"dashboardConfigItem:read"})
*
*/
private array $metadata = [];

View File

@ -187,5 +187,4 @@ class NewsItem implements TrackCreationInterface, TrackUpdateInterface
{
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\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\Translation\TranslatorInterface;
class NewsItemType extends AbstractType
{
@ -36,12 +35,12 @@ class NewsItemType extends AbstractType
ChillDateType::class,
[
'required' => true,
'input' => 'datetime_immutable'
'input' => 'datetime_immutable',
]
)
->add('endDate', ChillDateType::class, [
'required' => false,
'input' => 'datetime_immutable'
'input' => 'datetime_immutable',
]);
}

View File

@ -1,5 +1,14 @@
<?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;
use Chill\MainBundle\Entity\NewsItem;
@ -7,11 +16,9 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ObjectRepository;
use Faker\Core\DateTime;
class NewsItemRepository implements ObjectRepository
{
private readonly EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
@ -24,40 +31,26 @@ class NewsItemRepository implements ObjectRepository
return $this->repository->createQueryBuilder($alias, $indexBy);
}
/**
* @inheritDoc
*/
public function find($id)
{
return $this->repository->find($id);
}
/**
* @inheritDoc
*/
public function findAll()
{
return $this->repository->findAll();
}
/**
* @inheritDoc
*/
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null)
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null)
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}
/**
* @inheritDoc
*/
public function findOneBy(array $criteria)
{
return $this->repository->findOneBy($criteria);
}
/**
* @inheritDoc
*/
public function getClassName()
{
return NewsItem::class;

View File

@ -11,13 +11,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\Serializer\Normalizer;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\DashboardItem;
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;
class NewsItemNormalizer implements NormalizerInterface
@ -30,7 +24,7 @@ class NewsItemNormalizer implements NormalizerInterface
'title' => $newsItem->getTitle(),
'content' => $newsItem->getContent(),
'startdate' => $newsItem->getStartDate(),
'enddate' => $newsItem->getEndDate()
'enddate' => $newsItem->getEndDate(),
];
}

View File

@ -2,13 +2,20 @@
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;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Create dashboard config item and news item
* Create dashboard config item and news item.
*/
final class Version20231108141141 extends AbstractMigration
{

View File

@ -100,7 +100,7 @@ class ThirdPartyType extends AbstractType
'label' => 'thirdparty.Contact data are confidential',
]);
// Institutional ThirdParty (parent)
// Institutional ThirdParty (parent)
} else {
$builder
->add('nameCompany', TextType::class, [