FOSCommentBundle symfony 3 critical error

147 Views Asked by At

im installing foscomment bundle in my project and im following the documentation provided with this bundle in git hub

this is the link

documentation git hub

and when i want to update my database schema this exception appears to me and i couldnt figure out what is the problem

 [2017-02-11 17:06:57] php.CRITICAL: Fatal Compile Error: Declaration of Group\GroupBundle\Entity\Comment::setThread() must be compatible with FOS\CommentBundle\Model\CommentInterface::setThread(FOS\CommentBundle\Model\ThreadInterface $thread) {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalErrorException(code: 0): Compile Error: Declaration of Group\\GroupBundle\\Entity\\Comment::setThread() must be compatible with FOS\\CommentBundle\\Model\\CommentInterface::setThread(FOS\\CommentBundle\\Model\\ThreadInterface $thread) at C:\\wamp\\www\\E-Randopi\\src\\Group\\GroupBundle\\Entity\\Comment.php:18)"} 


[Symfony\Component\Debug\Exception\FatalErrorException]                      
Compile Error: Declaration of Group\GroupBundle\Entity\Comment::setThread()  
 must be compatible with FOS\CommentBundle\Model\CommentInterface::setThrea  
 d(FOS\CommentBundle\Model\ThreadInterface $thread)                           


doctrine:schema:update [--complete] [--dump-sql] [-f|--force] [--em [EM]] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

this is my error output

error

this is my comment entity

<?php

 namespace Group\GroupBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use FOS\CommentBundle\Entity\Comment as BaseComment;


/**
   * Commentaire
  *
  * @ORM\Table(name="commentaire")
   * @ORM\Entity
   * @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")

 */
 class Comment extends BaseComment
{
/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;

/**
 * Thread of this comment
 *
 * @var Thread
 * @ORM\ManyToOne(targetEntity="Group\GroupBundle\Entity\Thread")
 */
protected $thread;

/**
 * @var string
 *
 * @ORM\Column(name="description", type="string", length=100, nullable=false)
 */
private $description;

/**
 * @var integer
 *
 * @ORM\Column(name="id_createur", type="integer", nullable=false)
 */
private $idCreateur;

/**
 * @var integer
 *
 * @ORM\Column(name="id_publication", type="integer", nullable=false)
 */
private $idPublication;

/**
 * @var string
 *
 * @ORM\Column(name="photo", type="string", length=100, nullable=false)
 */
private $photo;

/**
 * @var \DateTime
 *
 * @ORM\Column(name="date_commentaire", type="date", nullable=false)
 */
private $dateCommentaire;

/**
 * @return int
 */
public function getId()
{
    return $this->id;
}

/**
 * @param int $id
 */
public function setId($id)
{
    $this->id = $id;
}

/**
 * @return Thread
 */
public function getThread()
{
    return $this->thread;
}

/**
 * @param Thread $thread
 */
public function setThread($thread)
{
    $this->thread = $thread;
}

/**
 * @return string
 */
public function getDescription()
{
    return $this->description;
}

/**
 * @param string $description
 */
public function setDescription($description)
{
    $this->description = $description;
}

/**
 * @return int
 */
public function getIdCreateur()
{
    return $this->idCreateur;
}

/**
 * @param int $idCreateur
 */
public function setIdCreateur($idCreateur)
{
    $this->idCreateur = $idCreateur;
}

/**
 * @return int
 */
public function getIdPublication()
{
    return $this->idPublication;
}

/**
 * @param int $idPublication
 */
public function setIdPublication($idPublication)
{
    $this->idPublication = $idPublication;
}

/**
 * @return string
 */
public function getPhoto()
{
    return $this->photo;
}

/**
 * @param string $photo
 */
public function setPhoto($photo)
{
    $this->photo = $photo;
}

/**
 * @return \DateTime
 */
public function getDateCommentaire()
{
    return $this->dateCommentaire;
}

/**
 * @param \DateTime $dateCommentaire
 */
public function setDateCommentaire($dateCommentaire)
{
    $this->dateCommentaire = $dateCommentaire;
}


}
1

There are 1 best solutions below

0
On BEST ANSWER

The setThread() method must be declared according to CommentInterface::setThread() of the FOSCommentBundle which is:

/**
 * @param ThreadInterface $thread
 */
public function setThread(ThreadInterface $thread);

and your Comment::setThread() declaration is:

/**
 * @param Thread $thread
 */
public function setThread($thread)
{
    $this->thread = $thread;
}