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\Component\Form\CallbackTransformer;
|
||||
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\HiddenType;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
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\Security;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use Symfony\Component\Validator\Constraints\NotEqualTo;
|
||||
use function is_int;
|
||||
|
||||
class ReassignAccompanyingPeriodController extends AbstractController
|
||||
{
|
||||
private AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository;
|
||||
|
||||
private AccompanyingPeriodRepository $courseRepository;
|
||||
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
private EngineInterface $engine;
|
||||
|
||||
private FormFactoryInterface $formFactory;
|
||||
@ -50,10 +54,6 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
|
||||
private UserRepository $userRepository;
|
||||
|
||||
private AccompanyingPeriodRepository $courseRepository;
|
||||
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
public function __construct(
|
||||
AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository,
|
||||
UserRepository $userRepository,
|
||||
@ -64,8 +64,7 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
Security $security,
|
||||
UserRender $userRender,
|
||||
EntityManagerInterface $em
|
||||
)
|
||||
{
|
||||
) {
|
||||
$this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository;
|
||||
$this->engine = $engine;
|
||||
$this->formFactory = $formFactory;
|
||||
@ -95,12 +94,12 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
$total = $this->accompanyingPeriodACLAwareRepository->countByUserOpenedAccompanyingPeriod($userFrom);
|
||||
$paginator = $this->paginatorFactory->create($total);
|
||||
$periods = $this->accompanyingPeriodACLAwareRepository
|
||||
->findByUserOpenedAccompanyingPeriod(
|
||||
$userFrom,
|
||||
['openingDate' => 'ASC'],
|
||||
$paginator->getItemsPerPage(),
|
||||
$paginator->getCurrentPageFirstItemNumber()
|
||||
);
|
||||
->findByUserOpenedAccompanyingPeriod(
|
||||
$userFrom,
|
||||
['openingDate' => 'ASC'],
|
||||
$paginator->getItemsPerPage(),
|
||||
$paginator->getCurrentPageFirstItemNumber()
|
||||
);
|
||||
|
||||
$periodIds = [];
|
||||
|
||||
@ -114,17 +113,15 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
$assignForm->handleRequest($request);
|
||||
|
||||
if ($assignForm->isSubmitted()) {
|
||||
|
||||
if ($assignForm->isSubmitted()) {
|
||||
|
||||
$assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true);
|
||||
$userTo = $assignForm->get('userTo')->getData();
|
||||
$userFrom = $assignForm->get('userFrom')->getData();
|
||||
|
||||
foreach($assignPeriodIds as $periodId) {
|
||||
foreach ($assignPeriodIds as $periodId) {
|
||||
$period = $this->courseRepository->find($periodId);
|
||||
|
||||
if ($userFrom === $period->getUser()) {
|
||||
if ($period->getUser() === $userFrom) {
|
||||
$period->setUser($userTo);
|
||||
}
|
||||
}
|
||||
@ -135,7 +132,6 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
return $this->redirectToRoute('chill_course_list_reassign', [
|
||||
'form' => ['user' => $userFrom->getId()],
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,8 +172,8 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
{
|
||||
$defaultData = [
|
||||
'userFrom' => $userFrom,
|
||||
'periods' => json_encode($periodIds),
|
||||
'assignTo' => null
|
||||
'periods' => json_encode($periodIds),
|
||||
'assignTo' => null,
|
||||
];
|
||||
|
||||
$builder = $this->formFactory->createBuilder(FormType::class, $defaultData);
|
||||
@ -200,18 +196,20 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
]);
|
||||
|
||||
$builder->get('userFrom')->addModelTransformer(new CallbackTransformer(
|
||||
function (?User $user) {
|
||||
static function (?User $user) {
|
||||
if (null === $user) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $user->getId();
|
||||
},
|
||||
function (?string $id) {
|
||||
if (null === $id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -66,13 +66,13 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
|
||||
}
|
||||
|
||||
// if ($this->authorizationChecker->isGranted(AccompanyingPeriodVoter::REASSIGN_BULK, null)) {
|
||||
$menu->addChild($this->translator->trans('Accompanying courses of users'), [
|
||||
'route' => 'chill_course_list_reassign',
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 12,
|
||||
'icons' => ['task'],
|
||||
]);
|
||||
$menu->addChild($this->translator->trans('Accompanying courses of users'), [
|
||||
'route' => 'chill_course_list_reassign',
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 12,
|
||||
'icons' => ['task'],
|
||||
]);
|
||||
// }
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,8 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
*/
|
||||
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';
|
||||
|
||||
/**
|
||||
@ -88,8 +90,6 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
*/
|
||||
public const TOGGLE_INTENSITY = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_INTENSITY';
|
||||
|
||||
public const REASSIGN_BULK ='CHILL_PERSON_ACCOMPANYING_COURSE_REASSIGN_BULK';
|
||||
|
||||
private Security $security;
|
||||
|
||||
private VoterHelperInterface $voterHelper;
|
||||
|
Loading…
x
Reference in New Issue
Block a user