mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix cs
This commit is contained in:
parent
7e2fbf93f9
commit
eccc75aecf
@ -18,8 +18,6 @@ use Chill\MainBundle\Serializer\Model\Collection;
|
|||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||||
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
||||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationRepository;
|
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationRepository;
|
||||||
use DateTimeImmutable;
|
|
||||||
use DateInterval;
|
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
@ -39,10 +37,10 @@ class AccompanyingPeriodWorkEvaluationApiController
|
|||||||
|
|
||||||
private PaginatorFactory $paginatorFactory;
|
private PaginatorFactory $paginatorFactory;
|
||||||
|
|
||||||
private SerializerInterface $serializer;
|
|
||||||
|
|
||||||
private Security $security;
|
private Security $security;
|
||||||
|
|
||||||
|
private SerializerInterface $serializer;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
AccompanyingPeriodWorkEvaluationRepository $accompanyingPeriodWorkEvaluationRepository,
|
AccompanyingPeriodWorkEvaluationRepository $accompanyingPeriodWorkEvaluationRepository,
|
||||||
DocGeneratorTemplateRepository $docGeneratorTemplateRepository,
|
DocGeneratorTemplateRepository $docGeneratorTemplateRepository,
|
||||||
@ -92,8 +90,6 @@ class AccompanyingPeriodWorkEvaluationApiController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/api/1.0/person/accompanying-period/work/evaluation/my-near-end")
|
* @Route("/api/1.0/person/accompanying-period/work/evaluation/my-near-end")
|
||||||
* @param Request $request
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
*/
|
||||||
public function myWorksNearEndDate(Request $request): JsonResponse
|
public function myWorksNearEndDate(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
@ -101,8 +97,11 @@ class AccompanyingPeriodWorkEvaluationApiController
|
|||||||
->countNearMaxDateByUser($this->security->getUser());
|
->countNearMaxDateByUser($this->security->getUser());
|
||||||
$paginator = $this->paginatorFactory->create($total);
|
$paginator = $this->paginatorFactory->create($total);
|
||||||
$works = $this->accompanyingPeriodWorkEvaluationRepository
|
$works = $this->accompanyingPeriodWorkEvaluationRepository
|
||||||
->findNearMaxDateByUser($this->security->getUser(),
|
->findNearMaxDateByUser(
|
||||||
$paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber());
|
$this->security->getUser(),
|
||||||
|
$paginator->getItemsPerPage(),
|
||||||
|
$paginator->getCurrentPageFirstItemNumber()
|
||||||
|
);
|
||||||
|
|
||||||
$collection = new Collection($works, $paginator);
|
$collection = new Collection($works, $paginator);
|
||||||
|
|
||||||
|
@ -1,5 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
|
namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
@ -9,7 +18,6 @@ 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 UnexpectedValueException;
|
|
||||||
|
|
||||||
class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository
|
class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository
|
||||||
{
|
{
|
||||||
@ -20,6 +28,12 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository
|
|||||||
$this->repository = $entityManager->getRepository(AccompanyingPeriodWorkEvaluation::class);
|
$this->repository = $entityManager->getRepository(AccompanyingPeriodWorkEvaluation::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function countNearMaxDateByUser(User $user): int
|
||||||
|
{
|
||||||
|
return $this->buildQueryNearMaxDateByUser($user)
|
||||||
|
->select('count(e)')->getQuery()->getSingleScalarResult();
|
||||||
|
}
|
||||||
|
|
||||||
public function find($id): ?AccompanyingPeriodWorkEvaluation
|
public function find($id): ?AccompanyingPeriodWorkEvaluation
|
||||||
{
|
{
|
||||||
return $this->repository->find($id);
|
return $this->repository->find($id);
|
||||||
@ -34,10 +48,9 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $criteria
|
|
||||||
* @param array|null $orderBy
|
|
||||||
* @param int $limit
|
* @param int $limit
|
||||||
* @param int $offset
|
* @param int $offset
|
||||||
|
*
|
||||||
* @return array|AccompanyingPeriodWorkEvaluation[]|object[]
|
* @return array|AccompanyingPeriodWorkEvaluation[]|object[]
|
||||||
*/
|
*/
|
||||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||||
@ -45,22 +58,6 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository
|
|||||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findOneBy(array $criteria): ?AccompanyingPeriodWorkEvaluation
|
|
||||||
{
|
|
||||||
return $this->repository->findOneBy($criteria);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getClassName(): string
|
|
||||||
{
|
|
||||||
return AccompanyingPeriodWorkEvaluation::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function countNearMaxDateByUser(User $user): int
|
|
||||||
{
|
|
||||||
return $this->buildQueryNearMaxDateByUser($user)
|
|
||||||
->select('count(e)')->getQuery()->getSingleScalarResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findNearMaxDateByUser(User $user, int $limit = 20, int $offset = 0): array
|
public function findNearMaxDateByUser(User $user, int $limit = 20, int $offset = 0): array
|
||||||
{
|
{
|
||||||
return $this->buildQueryNearMaxDateByUser($user)
|
return $this->buildQueryNearMaxDateByUser($user)
|
||||||
@ -71,6 +68,16 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository
|
|||||||
->getResult();
|
->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function findOneBy(array $criteria): ?AccompanyingPeriodWorkEvaluation
|
||||||
|
{
|
||||||
|
return $this->repository->findOneBy($criteria);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getClassName(): string
|
||||||
|
{
|
||||||
|
return AccompanyingPeriodWorkEvaluation::class;
|
||||||
|
}
|
||||||
|
|
||||||
private function buildQueryNearMaxDateByUser(User $user): QueryBuilder
|
private function buildQueryNearMaxDateByUser(User $user): QueryBuilder
|
||||||
{
|
{
|
||||||
$qb = $this->repository->createQueryBuilder('e');
|
$qb = $this->repository->createQueryBuilder('e');
|
||||||
@ -87,7 +94,7 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository
|
|||||||
)
|
)
|
||||||
->setParameters([
|
->setParameters([
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'now' => new \DateTimeImmutable('now')
|
'now' => new DateTimeImmutable('now'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $qb;
|
return $qb;
|
||||||
|
@ -29,28 +29,6 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository
|
|||||||
$this->repository = $entityManager->getRepository(AccompanyingPeriodWork::class);
|
$this->repository = $entityManager->getRepository(AccompanyingPeriodWork::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildQueryNearEndDateByUser(User $user, DateTimeImmutable $since, DateTimeImmutable $until): QueryBuilder
|
|
||||||
{
|
|
||||||
$qb = $this->repository->createQueryBuilder('w');
|
|
||||||
|
|
||||||
$qb
|
|
||||||
->join('w.accompanyingPeriod', 'period')
|
|
||||||
->where(
|
|
||||||
$qb->expr()->andX(
|
|
||||||
$qb->expr()->eq('period.user', ':user'),
|
|
||||||
$qb->expr()->gte('w.endDate', ':since'),
|
|
||||||
$qb->expr()->lte('w.startDate', ':until')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
->setParameters([
|
|
||||||
'user' => $user,
|
|
||||||
'since' => $since,
|
|
||||||
'until' => $until,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $qb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function countByAccompanyingPeriod(AccompanyingPeriod $period): int
|
public function countByAccompanyingPeriod(AccompanyingPeriod $period): int
|
||||||
{
|
{
|
||||||
return $this->repository->countByAccompanyingPeriod($period);
|
return $this->repository->countByAccompanyingPeriod($period);
|
||||||
@ -152,4 +130,26 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository
|
|||||||
|
|
||||||
return $qb;
|
return $qb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function buildQueryNearEndDateByUser(User $user, DateTimeImmutable $since, DateTimeImmutable $until): QueryBuilder
|
||||||
|
{
|
||||||
|
$qb = $this->repository->createQueryBuilder('w');
|
||||||
|
|
||||||
|
$qb
|
||||||
|
->join('w.accompanyingPeriod', 'period')
|
||||||
|
->where(
|
||||||
|
$qb->expr()->andX(
|
||||||
|
$qb->expr()->eq('period.user', ':user'),
|
||||||
|
$qb->expr()->gte('w.endDate', ':since'),
|
||||||
|
$qb->expr()->lte('w.startDate', ':until')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
->setParameters([
|
||||||
|
'user' => $user,
|
||||||
|
'since' => $since,
|
||||||
|
'until' => $until,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $qb;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -478,11 +478,15 @@ final class SingleTaskController extends AbstractController
|
|||||||
case 'json':
|
case 'json':
|
||||||
$collection = new Collection($tasks, $paginator);
|
$collection = new Collection($tasks, $paginator);
|
||||||
|
|
||||||
return $this->json($collection, JsonResponse::HTTP_OK, [],
|
return $this->json(
|
||||||
['groups' => ['read']]);
|
$collection,
|
||||||
|
JsonResponse::HTTP_OK,
|
||||||
|
[],
|
||||||
|
['groups' => ['read']]
|
||||||
|
);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new BadRequestException("format not supported: $format");
|
throw new BadRequestException("format not supported: {$format}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@ use function array_keys;
|
|||||||
*
|
*
|
||||||
* @ORM\MappedSuperclass
|
* @ORM\MappedSuperclass
|
||||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||||
* "single_task": SingleTask::class
|
* "single_task": SingleTask::class
|
||||||
* })
|
* })
|
||||||
*/
|
*/
|
||||||
abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
|
abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user