i have installed the FOSCommentBundle, everythings works the input comment display as expected but i want to display 1 thread per entity, so i got many planning with different url, like this : /planning/id . But whenever i post a comment for example in the planning/1 . I got a permalink created in the thread entity. But when i want go to the planning/2, it's display the comment of the planning/1 thread and won't create another permalink for planning/2.
I don't understand what i've done wrong. So if you have any clue for my problem, i will be grateful.
I created 2 entity :
<?php
namespace Simon\CommentBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use FOS\CommentBundle\Entity\Comment as BaseComment;
use FOS\CommentBundle\Model\SignedCommentInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity
*/
class Comment extends BaseComment implements SignedCommentInterface
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* Thread of this comment
*
* @var Thread
* @ORM\ManyToOne(targetEntity="Simon\CommentBundle\Entity\Thread")
*/
protected $thread;
/**
* Author of comment
*
* @ORM\ManyToOne(targetEntity="Simon\UserBundle\Entity\User")
* @var User
*/
protected $author;
public function setAuthor(UserInterface $author)
{
$this->author = $author;
}
public function getAuthor()
{
return $this->author;
}
public function getAuthorName()
{
if (null === $this->getAuthor()) {
return 'Anonymous';
}
return $this->getAuthor()->getUsername();
}
}
<?php
namespace Simon\CommentBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use FOS\CommentBundle\Entity\Thread as BaseThread;
/**
* @ORM\Entity
* @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")
*/
class Thread extends BaseThread
{
/**
* @var string $id
*
* @ORM\Id
* @ORM\Column(type="string")
*/
protected $id;
}
And i just followed the documentation to display the comment on my planning twig view :
{% extends "layout.html.twig" %}
{% block content %}
<h2>Planning de {{app.user.name}}</h2>
<div class="row">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Lundi</th>
<th>Mardi</th>
<th>Mercredi</th>
<th>Jeudi</th>
<th>Vendredi</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Responsable</th>
{% for i in 1..5 %}
{% set assigned_user = null %}
{% for user in users if user.planningday == i%}
{% set assigned_user = user %}
{% endfor %}
<td>
{% if not assigned_user is null %}
<a href="{{path('fos_user_profile_show_name', {'username':assigned_user.username})}}"> {{assigned_user.name}} {{assigned_user.lastname}}</a>
{% endif %}
</td>
{% endfor %}
</tr>
<tr>
<th scope="row">Description</th>
{% for i in 1..5 %}
{% set assigned_user = null %}
{% for user in users if user.planningday == i%}
{% set assigned_user = user %}
{% endfor %}
<td>
{% if not assigned_user is null %}
{{assigned_user.planningcontent}}
{% endif %}
</td>
{% endfor %}
</tr>
</tbody>
</table>
<a href="{{path('planningsub', {id:planning.id})}}">Inscription</a>
</div>
<div class="row">
{% include 'FOSCommentBundle:Thread:async.html.twig' with {'id': 'foo'} %}
</div>
{% endblock %}
I found the solution.
<div class="row">
{% include 'FOSCommentBundle:Thread:async.html.twig' with {'id': 'planning'~planning.id} %}
</div>