diff --git a/src/Entity/Blog/Comment.php b/src/Entity/Blog/Comment.php index d9a0d92..edcbace 100644 --- a/src/Entity/Blog/Comment.php +++ b/src/Entity/Blog/Comment.php @@ -207,4 +207,17 @@ class Comment implements EntityInterface { return 'https://secure.gravatar.com/avatar/'.md5($this->getEmail()).'.jpg?s=90&d=retro'; } + + /** + * {@inheritdoc} + */ + public function __toString() + { + return sprintf( + '[%s] (%s) %s', + $this->getAuthor(), + $this->getCreatedAt()->format('d/m/Y'), + substr($this->getContent(), 0, 20).'…' + ); + } } diff --git a/src/Form/Blog/CommentType.php b/src/Form/Blog/CommentType.php index 0c3b7ce..f729c67 100644 --- a/src/Form/Blog/CommentType.php +++ b/src/Form/Blog/CommentType.php @@ -106,7 +106,6 @@ class CommentType extends AbstractType [ 'label' => 'Réponse à', 'class' => Comment::class, - 'choice_label' => 'author', 'required' => false, 'multiple' => false, 'attr' => [ diff --git a/templates/blog/comment_admin/index.html.twig b/templates/blog/comment_admin/index.html.twig index 3003ff7..2a2d787 100644 --- a/templates/blog/comment_admin/index.html.twig +++ b/templates/blog/comment_admin/index.html.twig @@ -42,7 +42,14 @@ {{ item.author }} - Dans {{ item.post.title }} + Dans {{ item.post.title }} + + {% if item.parentComment %} + en réponse à + + {{ item.parentComment }} + + {% endif %} diff --git a/templates/blog/comment_admin/show.html.twig b/templates/blog/comment_admin/show.html.twig index 6fb1a85..a1e29b1 100644 --- a/templates/blog/comment_admin/show.html.twig +++ b/templates/blog/comment_admin/show.html.twig @@ -49,11 +49,22 @@ {{ entity.post.title }} -
  • - Réponse à + {% if entity.parentComment %} +
  • + + Réponse à + + {{ entity.parentComment.author }} - {{ entity.parentComment.createdAt|date('d/m/Y H:i') }} + + - {{ entity.parentComment ? entity.parentComment.author : '-' }} -
  • + {% if entity.parentComment.createdAt.timestamp > 1538118768 %} {# 28/09/2018 #} + {{- entity.parentComment.content|markdown('comment') -}} + {% else %} + {{- entity.parentComment.content|comment -}} + {% endif %} + + {% endif %}
  • Status