Hola, estoy desarrollando una web con symfony y tengo un problema con dos entidades, quiero obtener todos los datos relacionados de una entidad pero cuando utlizo el get me da un error que no explica nada.
Este es el código de las dos entidades:
Código PHP:
<?php
namespace AcmeIndexBundleEntity;
use DoctrineORMMapping as ORM;
/**
* Stories
*
* @ORM\Table()
* @ORM\Entity
*/
class Stories
{
/**
* @ORM\OneToMany(targetEntity="Stories", mappedBy="reviews")
*/
protected $reviews;
public function __construct()
{
$this->reviews = new ArrayCollection();
}
/**
* @ORM\ManyToOne(targetEntity="Users", inversedBy="stories")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $users;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var \DateTime
*
* @ORM\Column(name="datetime", type="datetime")
*/
private $datetime;
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=30)
*/
private $title;
/**
* @var string
*
* @ORM\Column(name="story", type="string", length=10000)
*/
private $story;
/**
* @var string
*
* @ORM\Column(name="url", type="string", length=40)
*/
private $url;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set datetime
*
* @param \DateTime $datetime
* @return Stories
*/
public function setDatetime($datetime)
{
$this->datetime = $datetime;
return $this;
}
/**
* Get datetime
*
* @return \DateTime
*/
public function getDatetime()
{
return $this->datetime;
}
/**
* Set title
*
* @param string $title
* @return Stories
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set story
*
* @param string $story
* @return Stories
*/
public function setStory($story)
{
$this->story = $story;
return $this;
}
/**
* Get story
*
* @return string
*/
public function getStory()
{
return $this->story;
}
/**
* Set users
*
* @param \Acme\IndexBundle\Entity\Users $users
* @return Stories
*/
public function setUsers(AcmeIndexBundleEntityUsers $users = null)
{
$this->users = $users;
return $this;
}
/**
* Get users
*
* @return \Acme\IndexBundle\Entity\Users
*/
public function getUsers()
{
return $this->users;
}
/**
* Set url
*
* @param string $url
* @return Stories
*/
public function setUrl($url)
{
$this->url = $url;
return $this;
}
/**
* Get url
*
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Add reviews
*
* @param \Acme\IndexBundle\Entity\Stories $reviews
* @return Stories
*/
public function addReview(AcmeIndexBundleEntityStories $reviews)
{
$this->reviews[] = $reviews;
return $this;
}
/**
* Remove reviews
*
* @param \Acme\IndexBundle\Entity\Stories $reviews
*/
public function removeReview(AcmeIndexBundleEntityStories $reviews)
{
$this->reviews->removeElement($reviews);
}
/**
* Get reviews
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getReviews()
{
return $this->reviews;
}
}
Código PHP:
<?php
namespace AcmeIndexBundleEntity;
use DoctrineORMMapping as ORM;
/**
* Reviews
*
* @ORM\Table()
* @ORM\Entity
*/
class Reviews
{
public function __construct()
{
$this->datetime = new DateTime();
}
/**
* @var integer
* @ORM\ManyToOne(targetEntity="Stories", inversedBy="reviews")
* @ORM\JoinColumn(name="story_id", referencedColumnName="id")
*/
protected $stories;
/**
* @ORM\ManyToOne(targetEntity="Users", inversedBy="reviews")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $users;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var \DateTime
*
* @ORM\Column(name="datetime", type="datetime")
*/
private $datetime;
/**
* @var string
*
* @ORM\Column(name="review", type="string", length=2000)
*/
private $review;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set datetime
*
* @param \DateTime $datetime
* @return Reviews
*/
public function setDatetime($datetime)
{
$this->datetime = $datetime;
return $this;
}
/**
* Get datetime
*
* @return \DateTime
*/
public function getDatetime()
{
return $this->datetime;
}
/**
* Set review
*
* @param string $review
* @return Reviews
*/
public function setReview($review)
{
$this->review = $review;
return $this;
}
/**
* Get review
*
* @return string
*/
public function getReview()
{
return $this->review;
}
/**
* Set stories
*
* @param \Acme\IndexBundle\Entity\Stories $stories
* @return Reviews
*/
public function setStories(AcmeIndexBundleEntityStories $stories = null)
{
$this->stories = $stories;
return $this;
}
/**
* Get stories
*
* @return \Acme\IndexBundle\Entity\Stories
*/
public function getStories()
{
return $this->stories;
}
/**
* Set users
*
* @param \Acme\IndexBundle\Entity\Users $users
* @return Reviews
*/
public function setUsers(AcmeIndexBundleEntityUsers $users = null)
{
$this->users = $users;
return $this;
}
/**
* Get users
*
* @return \Acme\IndexBundle\Entity\Users
*/
public function getUsers()
{
return $this->users;
}
}
El fallo me da al hacer la consulta en la tabla Stories cuando uso el método getReviews().
He seguido todos los pasos que vienen en este manual [URL="http://librosweb.es/symfony_2_x/capitulo_8/un_ejemplo_sencillo.html"]http://librosweb.es/symfony_2_x/capitulo_8/un_ejemplo_sencillo.html[/URL]
Gracias de antemano, saludos!