This commit is contained in:
2022-02-08 19:37:59 +01:00
parent 6b571e87b4
commit 1e81256404
8 changed files with 36 additions and 33 deletions

View File

@@ -44,8 +44,8 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
{
/**
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
* @Serializer\Groups({"read","read:accompanyingPeriodWork:light"})
* @Serializer\Context(normalizationContext={"groups"={"read"}}, groups={"read:accompanyingPeriodWork:light"})
* @Serializer\Groups({"read", "read:accompanyingPeriodWork:light"})
* @Serializer\Context(normalizationContext={"groups": {"read"}}, groups={"read:accompanyingPeriodWork:light"})
*/
private ?AccompanyingPeriod $accompanyingPeriod = null;

View File

@@ -75,7 +75,6 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
], ])
->setExtras(['order' => 30]);
$menu->addChild($this->translator->trans('Accompanying Course Comment'), [
'route' => 'chill_person_accompanying_period_comment_list',
'routeParameters' => [
@@ -93,7 +92,6 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
->setExtras(['order' => 40]);
}
$workflow = $this->registry->get($period, 'accompanying_period_lifecycle');
if (null !== $period->getClosingDate()) {

View File

@@ -25,10 +25,10 @@ use Doctrine\Persistence\ObjectRepository;
final class AccompanyingPeriodWorkRepository implements ObjectRepository
{
private EntityRepository $repository;
private EntityManagerInterface $em;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{
$this->em = $entityManager;
@@ -84,7 +84,7 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository
}
/**
* Return a list of accompanying period with a defined order:
* Return a list of accompanying period with a defined order:.
*
* * first, opened works
* * then, closed works
@@ -96,7 +96,7 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository
$rsm = new ResultSetMappingBuilder($this->em);
$rsm->addRootEntityFromClassMetadata(AccompanyingPeriodWork::class, 'w');
$sql = "SELECT ${rsm} FROM chill_person_accompanying_period_work w
$sql = "SELECT {$rsm} FROM chill_person_accompanying_period_work w
WHERE accompanyingPeriod_id = :periodId
ORDER BY
CASE WHEN enddate IS NULL THEN '-infinity'::timestamp ELSE 'infinity'::timestamp END ASC,
@@ -108,8 +108,7 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository
$nq = $this->em->createNativeQuery($sql, $rsm)
->setParameter('periodId', $period->getId(), Types::INTEGER)
->setParameter('limit', $limit, Types::INTEGER)
->setParameter('offset', $offset, Types::INTEGER)
;
->setParameter('offset', $offset, Types::INTEGER);
return $nq->getResult();
}

View File

@@ -17,12 +17,15 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use Symfony\Component\Security\Core\Security;
use UnexpectedValueException;
use function get_class;
use function in_array;
class AccompanyingPeriodWorkVoter extends Voter
{
public const CREATE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_CREATE';
public const SEE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_SEE';
public const UPDATE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE';
private Security $security;
@@ -40,7 +43,7 @@ class AccompanyingPeriodWorkVoter extends Voter
&& in_array($attribute, $this->getRoles(), true)
) || (
$subject instanceof AccompanyingPeriod
&& in_array($attribute, [self::SEE, self::CREATE])
&& in_array($attribute, [self::SEE, self::CREATE], true)
);
}
@@ -64,8 +67,10 @@ class AccompanyingPeriodWorkVoter extends Voter
return $this->security->isGranted(AccompanyingPeriodVoter::SEE_DETAILS, $subject);
default:
throw new UnexpectedValueException(sprintf("attribute {$attribute} is not supported on instance %s",
AccompanyingPeriod::class));
throw new UnexpectedValueException(sprintf(
"attribute {$attribute} is not supported on instance %s",
AccompanyingPeriod::class
));
}
}