mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
csfixes
This commit is contained in:
parent
f681e50167
commit
92c04c545f
@ -22,8 +22,8 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Form\CallbackTransformer;
|
use Symfony\Component\Form\CallbackTransformer;
|
||||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
use Symfony\Component\Form\FormFactoryInterface;
|
use Symfony\Component\Form\FormFactoryInterface;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@ -32,12 +32,16 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
use Symfony\Component\Templating\EngineInterface;
|
use Symfony\Component\Templating\EngineInterface;
|
||||||
use Symfony\Component\Validator\Constraints\NotEqualTo;
|
use function is_int;
|
||||||
|
|
||||||
class ReassignAccompanyingPeriodController extends AbstractController
|
class ReassignAccompanyingPeriodController extends AbstractController
|
||||||
{
|
{
|
||||||
private AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository;
|
private AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository;
|
||||||
|
|
||||||
|
private AccompanyingPeriodRepository $courseRepository;
|
||||||
|
|
||||||
|
private EntityManagerInterface $em;
|
||||||
|
|
||||||
private EngineInterface $engine;
|
private EngineInterface $engine;
|
||||||
|
|
||||||
private FormFactoryInterface $formFactory;
|
private FormFactoryInterface $formFactory;
|
||||||
@ -50,10 +54,6 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
|||||||
|
|
||||||
private UserRepository $userRepository;
|
private UserRepository $userRepository;
|
||||||
|
|
||||||
private AccompanyingPeriodRepository $courseRepository;
|
|
||||||
|
|
||||||
private EntityManagerInterface $em;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository,
|
AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository,
|
||||||
UserRepository $userRepository,
|
UserRepository $userRepository,
|
||||||
@ -64,8 +64,7 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
|||||||
Security $security,
|
Security $security,
|
||||||
UserRender $userRender,
|
UserRender $userRender,
|
||||||
EntityManagerInterface $em
|
EntityManagerInterface $em
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
$this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository;
|
$this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository;
|
||||||
$this->engine = $engine;
|
$this->engine = $engine;
|
||||||
$this->formFactory = $formFactory;
|
$this->formFactory = $formFactory;
|
||||||
@ -95,12 +94,12 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
|||||||
$total = $this->accompanyingPeriodACLAwareRepository->countByUserOpenedAccompanyingPeriod($userFrom);
|
$total = $this->accompanyingPeriodACLAwareRepository->countByUserOpenedAccompanyingPeriod($userFrom);
|
||||||
$paginator = $this->paginatorFactory->create($total);
|
$paginator = $this->paginatorFactory->create($total);
|
||||||
$periods = $this->accompanyingPeriodACLAwareRepository
|
$periods = $this->accompanyingPeriodACLAwareRepository
|
||||||
->findByUserOpenedAccompanyingPeriod(
|
->findByUserOpenedAccompanyingPeriod(
|
||||||
$userFrom,
|
$userFrom,
|
||||||
['openingDate' => 'ASC'],
|
['openingDate' => 'ASC'],
|
||||||
$paginator->getItemsPerPage(),
|
$paginator->getItemsPerPage(),
|
||||||
$paginator->getCurrentPageFirstItemNumber()
|
$paginator->getCurrentPageFirstItemNumber()
|
||||||
);
|
);
|
||||||
|
|
||||||
$periodIds = [];
|
$periodIds = [];
|
||||||
|
|
||||||
@ -114,17 +113,15 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
|||||||
$assignForm->handleRequest($request);
|
$assignForm->handleRequest($request);
|
||||||
|
|
||||||
if ($assignForm->isSubmitted()) {
|
if ($assignForm->isSubmitted()) {
|
||||||
|
|
||||||
if ($assignForm->isSubmitted()) {
|
if ($assignForm->isSubmitted()) {
|
||||||
|
|
||||||
$assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true);
|
$assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true);
|
||||||
$userTo = $assignForm->get('userTo')->getData();
|
$userTo = $assignForm->get('userTo')->getData();
|
||||||
$userFrom = $assignForm->get('userFrom')->getData();
|
$userFrom = $assignForm->get('userFrom')->getData();
|
||||||
|
|
||||||
foreach($assignPeriodIds as $periodId) {
|
foreach ($assignPeriodIds as $periodId) {
|
||||||
$period = $this->courseRepository->find($periodId);
|
$period = $this->courseRepository->find($periodId);
|
||||||
|
|
||||||
if ($userFrom === $period->getUser()) {
|
if ($period->getUser() === $userFrom) {
|
||||||
$period->setUser($userTo);
|
$period->setUser($userTo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,7 +132,6 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
|||||||
return $this->redirectToRoute('chill_course_list_reassign', [
|
return $this->redirectToRoute('chill_course_list_reassign', [
|
||||||
'form' => ['user' => $userFrom->getId()],
|
'form' => ['user' => $userFrom->getId()],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,8 +172,8 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
|||||||
{
|
{
|
||||||
$defaultData = [
|
$defaultData = [
|
||||||
'userFrom' => $userFrom,
|
'userFrom' => $userFrom,
|
||||||
'periods' => json_encode($periodIds),
|
'periods' => json_encode($periodIds),
|
||||||
'assignTo' => null
|
'assignTo' => null,
|
||||||
];
|
];
|
||||||
|
|
||||||
$builder = $this->formFactory->createBuilder(FormType::class, $defaultData);
|
$builder = $this->formFactory->createBuilder(FormType::class, $defaultData);
|
||||||
@ -200,18 +196,20 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->get('userFrom')->addModelTransformer(new CallbackTransformer(
|
$builder->get('userFrom')->addModelTransformer(new CallbackTransformer(
|
||||||
function (?User $user) {
|
static function (?User $user) {
|
||||||
if (null === $user) {
|
if (null === $user) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user->getId();
|
return $user->getId();
|
||||||
},
|
},
|
||||||
function (?string $id) {
|
function (?string $id) {
|
||||||
if (null === $id) {
|
if (null === $id) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_int((int) $id)) {
|
if (!is_int((int) $id)) {
|
||||||
throw new TransformationFailedException("the user id is not a numeric");
|
throw new TransformationFailedException('the user id is not a numeric');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->userRepository->find((int) $id);
|
return $this->userRepository->find((int) $id);
|
||||||
|
@ -66,13 +66,13 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if ($this->authorizationChecker->isGranted(AccompanyingPeriodVoter::REASSIGN_BULK, null)) {
|
// if ($this->authorizationChecker->isGranted(AccompanyingPeriodVoter::REASSIGN_BULK, null)) {
|
||||||
$menu->addChild($this->translator->trans('Accompanying courses of users'), [
|
$menu->addChild($this->translator->trans('Accompanying courses of users'), [
|
||||||
'route' => 'chill_course_list_reassign',
|
'route' => 'chill_course_list_reassign',
|
||||||
])
|
])
|
||||||
->setExtras([
|
->setExtras([
|
||||||
'order' => 12,
|
'order' => 12,
|
||||||
'icons' => ['task'],
|
'icons' => ['task'],
|
||||||
]);
|
]);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +67,8 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
|||||||
*/
|
*/
|
||||||
public const RE_OPEN_COURSE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_REOPEN';
|
public const RE_OPEN_COURSE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_REOPEN';
|
||||||
|
|
||||||
|
public const REASSIGN_BULK = 'CHILL_PERSON_ACCOMPANYING_COURSE_REASSIGN_BULK';
|
||||||
|
|
||||||
public const SEE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE';
|
public const SEE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,8 +90,6 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
|||||||
*/
|
*/
|
||||||
public const TOGGLE_INTENSITY = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_INTENSITY';
|
public const TOGGLE_INTENSITY = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_INTENSITY';
|
||||||
|
|
||||||
public const REASSIGN_BULK ='CHILL_PERSON_ACCOMPANYING_COURSE_REASSIGN_BULK';
|
|
||||||
|
|
||||||
private Security $security;
|
private Security $security;
|
||||||
|
|
||||||
private VoterHelperInterface $voterHelper;
|
private VoterHelperInterface $voterHelper;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user