Browse Source

update admin of comments

develop
Simon Vieille 2 weeks ago
parent
commit
b8d64f307f
  1. 13
      src/Entity/Blog/Comment.php
  2. 1
      src/Form/Blog/CommentType.php
  3. 9
      templates/blog/comment_admin/index.html.twig
  4. 19
      templates/blog/comment_admin/show.html.twig

13
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).'…'
);
}
}

1
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' => [

9
templates/blog/comment_admin/index.html.twig

@ -42,7 +42,14 @@
{{ item.author }}
</a>
Dans <a href="">{{ item.post.title }}</a>
Dans <a href="{{ path('admin_blog_post_show', {entity: item.post.id}) }}">{{ item.post.title }}</a>
{% if item.parentComment %}
en réponse à
<a href="{{ path('admin_blog_comment_show', {entity: item.parentComment.id}) }}">
{{ item.parentComment }}
</a>
{% endif %}
</td>
<td class="col-2">
<span class="btn btn-sm btn-light">

19
templates/blog/comment_admin/show.html.twig

@ -49,11 +49,22 @@
{{ entity.post.title }}
</li>
<li class="list-group-item">
<span class="font-weight-bold pb-2 d-block">Réponse à</span>
{% if entity.parentComment %}
<li class="list-group-item">
<span class="font-weight-bold pb-2 d-block">
Réponse à
<a href="{{ path('admin_blog_comment_show', {entity: entity.parentComment.id}) }}">
{{ entity.parentComment.author }} - {{ entity.parentComment.createdAt|date('d/m/Y H:i') }}
</a>
</span>
{{ entity.parentComment ? entity.parentComment.author : '-' }}
</li>
{% if entity.parentComment.createdAt.timestamp > 1538118768 %} {# 28/09/2018 #}
{{- entity.parentComment.content|markdown('comment') -}}
{% else %}
{{- entity.parentComment.content|comment -}}
{% endif %}
</li>
{% endif %}
<li class="list-group-item">
<span class="font-weight-bold pb-2 d-block">Status</span>

Loading…
Cancel
Save