mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
unpin comment is possible + delete and edit by all users that can edit period
This commit is contained in:
@@ -84,7 +84,7 @@ class AccompanyingCourseCommentController extends AbstractController
|
||||
}
|
||||
|
||||
if (isset($commentEdited)) {
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodCommentVoter::EDIT, $commentEdited);
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $commentEdited->getAccompanyingPeriod());
|
||||
} else {
|
||||
throw new LogicException('at this step, commentEdited should be set');
|
||||
}
|
||||
@@ -135,7 +135,7 @@ class AccompanyingCourseCommentController extends AbstractController
|
||||
*/
|
||||
public function deleteAction(AccompanyingPeriod\Comment $comment, Request $request): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodCommentVoter::DELETE, $comment);
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $comment->getAccompanyingPeriod());
|
||||
|
||||
$form = $this->createForm(FormType::class, []);
|
||||
$form->add('submit', SubmitType::class, ['label' => 'Confirm']);
|
||||
@@ -186,6 +186,24 @@ class AccompanyingCourseCommentController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/parcours/comment/{id}/unpin", name="chill_person_accompanying_period_comment_unpin")
|
||||
*/
|
||||
public function unpinComment(AccompanyingPeriod\Comment $comment): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $comment->getAccompanyingPeriod());
|
||||
|
||||
$comment->getAccompanyingPeriod()->setPinnedComment(null);
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
$this->addFlash('success', $this->translator->trans('accompanying_course.comment is unpinned'));
|
||||
|
||||
return $this->redirectToRoute('chill_person_accompanying_period_comment_list', [
|
||||
'accompanying_period_id' => $comment->getAccompanyingPeriod()->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
private function createCommentForm(AccompanyingPeriod\Comment $comment, string $step): FormInterface
|
||||
{
|
||||
return $this->formFactory->createNamed($step, AccompanyingCourseCommentType::class, $comment);
|
||||
|
Reference in New Issue
Block a user