Всем привет!
Есть сущности (упрощенные):
<?php
namespace AppBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Brand
*
* @ORM\Table(name="brand")
* @ORM\Entity(repositoryClass="AppBundle\Repository\BrandRepository")
*/
class Brand
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* 1 brand:many products
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Product",
* mappedBy="brand")
*/
private $products;
public function __construct() {
parent::__construct();
$this->products = new ArrayCollection();
}
/**
* Get products
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getProducts()
{
return $this->products;
}
}
?>
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Product
*
* @ORM\Table(name="product")
* @ORM\Entity(repositoryClass=AppBundle\Repository\ProductRepository")
*/
class Product
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* many prodcuts : 1 brand
* @var integer
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Brand", inversedBy="products")
*/
private $brand;
}
?>
Все ли верно? Почему не могу получить products?