mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'master' into notification/completion
This commit is contained in:
commit
f79225fc2b
@ -6,14 +6,20 @@
|
|||||||
<p class="message-confirm">{{ confirm_question }}</p>
|
<p class="message-confirm">{{ confirm_question }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if display_content is not empty %}
|
||||||
|
{{ display_content|raw }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{{ form_start(form) }}
|
{{ form_start(form) }}
|
||||||
|
|
||||||
<ul class="record_actions sticky-form-buttons">
|
<ul class="record_actions sticky-form-buttons">
|
||||||
<li class="cancel">
|
{% if cancel_route is defined %}
|
||||||
<a href="{{ path(cancel_route, cancel_parameters|default( { } ) ) }}" class="btn btn-cancel">
|
<li class="cancel">
|
||||||
{{ 'Cancel'|trans }}
|
<a href="{{ chill_path_forward_return_path(cancel_route, cancel_parameters|default( { } ) ) }}" class="btn btn-cancel">
|
||||||
</a>
|
{{ 'Cancel'|trans }}
|
||||||
</li>
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
<li>
|
<li>
|
||||||
{{ form_widget(form.submit, { 'attr' : { 'class' : "btn btn-delete" } } ) }}
|
{{ form_widget(form.submit, { 'attr' : { 'class' : "btn btn-delete" } } ) }}
|
||||||
</li>
|
</li>
|
||||||
|
@ -13,20 +13,41 @@ namespace Chill\PersonBundle\Controller;
|
|||||||
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Form\AccompanyingCourseCommentType;
|
use Chill\PersonBundle\Form\AccompanyingCourseCommentType;
|
||||||
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodCommentVoter;
|
||||||
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use LogicException;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
|
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;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
|
||||||
|
|
||||||
use function array_key_exists;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class AccompanyingCourseCommentController extends AbstractController
|
class AccompanyingCourseCommentController extends AbstractController
|
||||||
{
|
{
|
||||||
|
private EntityManagerInterface $entityManager;
|
||||||
|
|
||||||
|
private FormFactoryInterface $formFactory;
|
||||||
|
|
||||||
|
private TranslatorInterface $translator;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
EntityManagerInterface $entityManager,
|
||||||
|
FormFactoryInterface $formFactory,
|
||||||
|
TranslatorInterface $translator
|
||||||
|
) {
|
||||||
|
$this->entityManager = $entityManager;
|
||||||
|
$this->formFactory = $formFactory;
|
||||||
|
$this->translator = $translator;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page of comments in Accompanying Course section.
|
* Page of comments in Accompanying Course section.
|
||||||
*
|
*
|
||||||
@ -35,107 +56,139 @@ class AccompanyingCourseCommentController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
public function commentAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response
|
public function commentAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response
|
||||||
{
|
{
|
||||||
$newComment = new AccompanyingPeriod\Comment();
|
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE_DETAILS, $accompanyingCourse);
|
||||||
$newComment->setAccompanyingPeriod($accompanyingCourse);
|
|
||||||
|
|
||||||
$form = $this->createCommentForm($newComment, 'new');
|
$em = $this->getDoctrine()->getManager();
|
||||||
$editForm = null;
|
$afterSuccessfulRedirectResponse = $this->redirectToRoute('chill_person_accompanying_period_comment_list', [
|
||||||
|
'accompanying_period_id' => $accompanyingCourse->getId(),
|
||||||
|
]);
|
||||||
|
|
||||||
if ($request->query->has('edit')) {
|
if ($request->query->has('edit') && $this->isGranted(AccompanyingPeriodVoter::EDIT, $accompanyingCourse)) {
|
||||||
foreach ($accompanyingCourse->getComments() as $comment) {
|
foreach ($accompanyingCourse->getComments() as $comment) {
|
||||||
if ($comment->getId() === $request->query->getInt('edit')) {
|
if ($comment->getId() === $request->query->getInt('edit')) {
|
||||||
$editForm = $this->createCommentForm($comment, 'edit');
|
$editForm = $this->createCommentForm($comment, 'edit');
|
||||||
$commentEditId = $comment->getId();
|
$commentEditId = $comment->getId();
|
||||||
|
$commentEdited = $comment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$pinnedComment = $accompanyingCourse->getPinnedComment();
|
$pinnedComment = $accompanyingCourse->getPinnedComment();
|
||||||
|
|
||||||
if ($pinnedComment->getId() === $request->query->getInt('edit')) {
|
if (null !== $pinnedComment && $pinnedComment->getId() === $request->query->getInt('edit')) {
|
||||||
$editForm = $this->createCommentForm($pinnedComment, 'edit');
|
$editForm = $this->createCommentForm($pinnedComment, 'edit');
|
||||||
$commentEditId = $pinnedComment->getId();
|
$commentEditId = $pinnedComment->getId();
|
||||||
|
$commentEdited = $pinnedComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($editForm)) {
|
||||||
|
throw new NotFoundHttpException('comment with id ' . $request->query->getInt('edit') . ' is not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($commentEdited)) {
|
||||||
|
$this->denyAccessUnlessGranted(AccompanyingPeriodCommentVoter::EDIT, $commentEdited);
|
||||||
|
} else {
|
||||||
|
throw new LogicException('at this step, commentEdited should be set');
|
||||||
|
}
|
||||||
|
|
||||||
|
$editForm->handleRequest($request);
|
||||||
|
|
||||||
|
if ($editForm->isSubmitted() && $editForm->isValid()) {
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
return $afterSuccessfulRedirectResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($editForm->isSubmitted() && !$editForm->isValid()) {
|
||||||
|
$this->addFlash('error', $this->translator->trans('This form contains errors'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dump($editForm);
|
if ($this->isGranted(AccompanyingPeriodVoter::EDIT, $accompanyingCourse)) {
|
||||||
//if (null === $editForm) {
|
$newComment = new AccompanyingPeriod\Comment();
|
||||||
// throw new NotFoundHttpException('Unable to find an edit form.');
|
$newComment->setAccompanyingPeriod($accompanyingCourse);
|
||||||
//}
|
|
||||||
|
|
||||||
if ($request->getMethod() === Request::METHOD_POST) {
|
$newForm = $this->createCommentForm($newComment, 'new');
|
||||||
$currentForm = $editForm->handleRequest($request);
|
$newForm->handleRequest($request);
|
||||||
|
|
||||||
if (array_key_exists('edit', $request->request->all()[$editForm->getName()])) {
|
if ($newForm->isSubmitted() && $newForm->isValid()) {
|
||||||
$isEditingNew = false;
|
$em->persist($newComment);
|
||||||
} else {
|
|
||||||
$isEditingNew = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($currentForm->isSubmitted() && $currentForm->isValid()) {
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
if ($isEditingNew) {
|
|
||||||
$em->persist($newComment);
|
|
||||||
}
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
}
|
|
||||||
|
|
||||||
return $this->redirectToRoute('chill_person_accompanying_period_comment_list', [
|
return $afterSuccessfulRedirectResponse;
|
||||||
'accompanying_period_id' => $accompanyingCourse->getId(),
|
}
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('@ChillPerson/AccompanyingCourse/Comment/index.html.twig', [
|
return $this->render('@ChillPerson/AccompanyingCourse/Comment/index.html.twig', [
|
||||||
'accompanyingCourse' => $accompanyingCourse,
|
'accompanyingCourse' => $accompanyingCourse,
|
||||||
'form' => $form->createView(),
|
'form' => isset($newForm) ? $newForm->createView() : null,
|
||||||
'edit_form' => null !== $editForm ? $editForm->createView() : null,
|
'edit_form' => isset($editForm) ? $editForm->createView() : null,
|
||||||
'commentEditId' => $commentEditId ?? null,
|
'commentEditId' => $commentEditId ?? null,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete an existing comment.
|
||||||
|
*
|
||||||
|
* @Route(
|
||||||
|
* "/{_locale}/parcours/comment/{id}/delete",
|
||||||
|
* name="chill_person_accompanying_period_comment_delete"
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
public function deleteAction(AccompanyingPeriod\Comment $comment, Request $request): Response
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted(AccompanyingPeriodCommentVoter::DELETE, $comment);
|
||||||
|
|
||||||
|
$form = $this->createForm(FormType::class, []);
|
||||||
|
$form->add('submit', SubmitType::class, ['label' => 'Confirm']);
|
||||||
|
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
$this->entityManager->remove($comment);
|
||||||
|
|
||||||
|
if ($comment->getAccompanyingPeriod()->getPinnedComment() === $comment) {
|
||||||
|
$comment->getAccompanyingPeriod()->setPinnedComment(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
$this->addFlash('success', $this->translator->trans('accompanying_course_comment.Comment removed'));
|
||||||
|
|
||||||
|
return $this->redirect(
|
||||||
|
$request->query->has('returnPath') ? $request->query->get('returnPath') :
|
||||||
|
$this->generateUrl('chill_person_accompanying_period_comment_list', [
|
||||||
|
'accompanying_period_id' => $comment->getAccompanyingPeriod()->getId(),
|
||||||
|
])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('@ChillPerson/AccompanyingCourse/Comment/confirm_delete.html.twig', [
|
||||||
|
'comment' => $comment,
|
||||||
|
'delete_form' => $form->createView(),
|
||||||
|
'accompanyingCourse' => $comment->getAccompanyingPeriod(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/{_locale}/parcours/comment/{id}/pin", name="chill_person_accompanying_period_comment_pin")
|
||||||
|
*/
|
||||||
|
public function pinComment(AccompanyingPeriod\Comment $comment): Response
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $comment->getAccompanyingPeriod());
|
||||||
|
|
||||||
|
$comment->getAccompanyingPeriod()->setPinnedComment($comment);
|
||||||
|
|
||||||
|
$this->getDoctrine()->getManager()->flush();
|
||||||
|
|
||||||
|
$this->addFlash('success', $this->translator->trans('accompanying_course.comment is pinned'));
|
||||||
|
|
||||||
|
return $this->redirectToRoute('chill_person_accompanying_period_comment_list', [
|
||||||
|
'accompanying_period_id' => $comment->getAccompanyingPeriod()->getId(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
private function createCommentForm(AccompanyingPeriod\Comment $comment, string $step): FormInterface
|
private function createCommentForm(AccompanyingPeriod\Comment $comment, string $step): FormInterface
|
||||||
{
|
{
|
||||||
$form = $this->createForm(AccompanyingCourseCommentType::class, $comment);
|
return $this->formFactory->createNamed($step, AccompanyingCourseCommentType::class, $comment);
|
||||||
|
|
||||||
if ('edit' === $step) {
|
|
||||||
$form->add('edit', HiddenType::class, ['mapped' => false]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $form;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////// building
|
|
||||||
///
|
|
||||||
// /**
|
|
||||||
// * Delete an existing comment
|
|
||||||
// *
|
|
||||||
// * @Route(
|
|
||||||
// * "/{_locale}/parcours/{accompanying_period_id}/comment/{comment_id}/delete",
|
|
||||||
// * name="chill_person_accompanying_period_comment_delete"
|
|
||||||
// * )
|
|
||||||
// * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
|
||||||
// * @ParamConverter("comment", options={"id": "comment_id"})
|
|
||||||
// */
|
|
||||||
// public function deleteAction(AccompanyingPeriod $accompanyingCourse, AccompanyingPeriod\Comment $comment, Request $request)
|
|
||||||
// {
|
|
||||||
// $form = $this->createDeleteForm($comment->getId(), $accompanyingCourse);
|
|
||||||
//
|
|
||||||
// return $this->render('@ChillPerson/AccompanyingCourse/Comment/confirm_delete.html.twig', [
|
|
||||||
// 'comment' => $comment,
|
|
||||||
// 'delete_form' => $form->createView(),
|
|
||||||
// 'accompanyingCourse' => $accompanyingCourse,
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private function createDeleteForm(int $id, ?AccompanyingPeriod $accompanyingCourse): FormInterface
|
|
||||||
// {
|
|
||||||
// $form = $this->createForm($type);
|
|
||||||
//
|
|
||||||
// return $this->createFormBuilder()
|
|
||||||
// ->setAction($this->generateUrl('chill_person_accompanying_period_comment_delete', $params))
|
|
||||||
// ->setMethod('DELETE')
|
|
||||||
// ->add('submit', SubmitType::class, ['label' => 'Delete'])
|
|
||||||
// ->getForm();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//// end
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,9 @@ class AccompanyingCourseCommentType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$builder->add('content', ChillTextareaType::class, []);
|
$builder->add('content', ChillTextareaType::class, [
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,20 +1,19 @@
|
|||||||
{# WIP
|
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
|
||||||
|
|
||||||
{% extends "@ChillPerson/Person/layout.html.twig" %}
|
{% block title 'accompanying_course_comment.Remove comment'|trans %}
|
||||||
|
|
||||||
{% set person = activity.person %}
|
{% block display_content %}
|
||||||
|
<blockquote class="chill-user-quote col">{{ comment.content|chill_markdown_to_html }}</blockquote>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block title 'Remove comment'|trans %}
|
{% block content %}
|
||||||
|
|
||||||
{% block personcontent %}
|
|
||||||
{{ include('@ChillMain/Util/confirmation_template.html.twig',
|
{{ include('@ChillMain/Util/confirmation_template.html.twig',
|
||||||
{
|
{
|
||||||
'title' : 'Remove comment'|trans,
|
'title' : 'accompanying_course_comment.Remove comment'|trans,
|
||||||
'confirm_question' : 'Are you sure you want to remove comment ?'|trans,
|
'confirm_question' : 'accompanying_course_comment.Are you sure you want to remove comment ?'|trans,
|
||||||
'cancel_route' : 'chill_activity_activity_list',
|
'cancel_route' : 'chill_person_accompanying_period_comment_list',
|
||||||
'cancel_parameters' : { 'person_id' : activity.person.id, 'id' : activity.id },
|
'cancel_parameters' : { 'accompanying_period_id': comment.accompanyingPeriod.id },
|
||||||
|
'display_content' : block('display_content'),
|
||||||
'form' : delete_form
|
'form' : delete_form
|
||||||
} ) }}
|
} ) }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
#}
|
|
||||||
|
@ -10,21 +10,27 @@
|
|||||||
{% if isPinned is defined and isPinned == 'true' %}
|
{% if isPinned is defined and isPinned == 'true' %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<li>
|
<li>
|
||||||
<button class="btn btn-sm btn-misc" type="button">
|
<form method="post" action="{{ chill_path_forward_return_path('chill_person_accompanying_period_comment_pin', {'id': comment.id}) }}">
|
||||||
<i class="fa fa-flag fa-fw"></i>{{ 'Pin comment'|trans }}
|
<button class="btn btn-sm btn-misc" type="submit">
|
||||||
</button>
|
<i class="fa fa-flag fa-fw"></i>{{ 'Pin comment'|trans }}
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_EDIT', comment) %}
|
||||||
|
<li>
|
||||||
|
<a class="btn btn-sm btn-edit" title="{{ 'Edit'|trans }}" href="{{ path('chill_person_accompanying_period_comment_list', {
|
||||||
|
'_fragment': 'comment-' ~ comment.id,
|
||||||
|
'edit': comment.id,
|
||||||
|
'accompanying_period_id': comment.accompanyingPeriod.id
|
||||||
|
}) }}"></a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_DELETE', comment) %}
|
||||||
|
<li>
|
||||||
|
<a class="btn btn-sm btn-delete" title="{{ 'Delete'|trans }}" href="{{ path('chill_person_accompanying_period_comment_delete', {'id': comment.id}) }}"></a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li>
|
|
||||||
<a class="btn btn-sm btn-edit" title="{{ 'Edit'|trans }}" href="{{ path('chill_person_accompanying_period_comment_list', {
|
|
||||||
'_fragment': 'comment-' ~ comment.id,
|
|
||||||
'edit': comment.id,
|
|
||||||
'accompanying_period_id': comment.accompanyingPeriod.id
|
|
||||||
}) }}"></a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a class="btn btn-sm btn-delete" title="{{ 'Delete'|trans }}" href=""></a>
|
|
||||||
</li>
|
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro form_comment(type, form) %}
|
{% macro form_comment(type, form) %}
|
||||||
@ -75,9 +81,12 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<div class="new-comment my-5">
|
|
||||||
<h2 class="chill-blue">{{ 'Write a new comment'|trans }}</h2>
|
{% if form is not null %}
|
||||||
{{ _self.form_comment('new', form) }}
|
<div class="new-comment my-5">
|
||||||
</div>
|
<h2 class="chill-blue">{{ 'Write a new comment'|trans }}</h2>
|
||||||
|
{{ _self.form_comment('new', form) }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -22,6 +22,3 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
{#
|
|
||||||
TODO if shared, move this file in Main, out of AccompanyingCourse
|
|
||||||
#}
|
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
<?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\Security\Authorization;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
||||||
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||||
|
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||||
|
use UnexpectedValueException;
|
||||||
|
|
||||||
|
class AccompanyingPeriodCommentVoter extends Voter
|
||||||
|
{
|
||||||
|
public const DELETE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_DELETE';
|
||||||
|
|
||||||
|
public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_EDIT';
|
||||||
|
|
||||||
|
protected function supports($attribute, $subject)
|
||||||
|
{
|
||||||
|
return $subject instanceof Comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
|
||||||
|
{
|
||||||
|
/** @var Comment $subject */
|
||||||
|
switch ($attribute) {
|
||||||
|
case self::EDIT:
|
||||||
|
case self::DELETE:
|
||||||
|
return $subject->getCreator() === $token->getUser();
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new UnexpectedValueException("This attribute {$attribute} is not supported");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,3 +12,7 @@ services:
|
|||||||
- { name: security.voter }
|
- { name: security.voter }
|
||||||
- { name: chill.role }
|
- { name: chill.role }
|
||||||
|
|
||||||
|
Chill\PersonBundle\Security\Authorization\AccompanyingPeriodCommentVoter:
|
||||||
|
autowire: true
|
||||||
|
tags:
|
||||||
|
- { name: security.voter }
|
||||||
|
@ -413,6 +413,7 @@ Locate by: Localiser auprès de
|
|||||||
fix it: Compléter
|
fix it: Compléter
|
||||||
accompanying_course:
|
accompanying_course:
|
||||||
administrative_location: Localisation administrative
|
administrative_location: Localisation administrative
|
||||||
|
comment is pinned: Le commentaire est épinglé
|
||||||
|
|
||||||
# Accompanying Course comments
|
# Accompanying Course comments
|
||||||
Accompanying Course Comment: Commentaire
|
Accompanying Course Comment: Commentaire
|
||||||
@ -422,6 +423,10 @@ Pin comment: Épingler
|
|||||||
Post a new comment: Poster un nouveau commentaire
|
Post a new comment: Poster un nouveau commentaire
|
||||||
Write a new comment: Écrire un nouveau commentaire
|
Write a new comment: Écrire un nouveau commentaire
|
||||||
Edit a comment: Modifier le commentaire
|
Edit a comment: Modifier le commentaire
|
||||||
|
accompanying_course_comment:
|
||||||
|
Comment removed: Commentaire supprimé
|
||||||
|
Remove comment: Supprimer le commentaire
|
||||||
|
Are you sure you want to remove comment ?: Étes-vous sûr de vouloir supprimer ce commentaire ?
|
||||||
|
|
||||||
# Household
|
# Household
|
||||||
Household: Ménage
|
Household: Ménage
|
||||||
|
Loading…
x
Reference in New Issue
Block a user