我有一个实体Prototype与项目有多对一的关系,我想覆盖CRUDController中的一个函数。
以下是代码:
$idPrototype = $this->get('request')->get($this->admin->getIdParameter());
我得到原型的id,但我想要参数' project' (项目的ID) 这是我的原型实体
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Prototype
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="AppBundle\Entity\PrototypeRepository")
*/
class Prototype
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="nom", type="string", length=255)
*/
private $nom;
/**
* @var string
*
* @ORM\Column(name="description", type="string", length=255)
*/
private $description;
/**
* @var \DateTime
*
* @ORM\Column(name="dateCreation", type="date")
*/
private $dateCreation;
private $projet;
public function __construct()
{
$this->dateCreation = new \DateTime("now");
$this->nom = "";
$this->description = " ";
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Get nom
*
* @return string
*/
public function getNom()
{
return $this->nom;
}
public function __toString()
{
return $this->getNom();
}
/**
* Set nom
*
* @param string $nom
* @return Prototype
*/
public function setNom($nom)
{
$this->nom = $nom;
return $this;
}
/**
* Set description
*
* @param string $description
* @return Prototype
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set dateCreation
*
* @param \DateTime $dateCreation
* @return Prototype
*/
public function setDateCreation($dateCreation)
{
$this->dateCreation = $dateCreation;
return $this;
}
/**
* Get dateCreation
*
* @return \DateTime
*/
public function getDateCreation()
{
return $this->dateCreation;
}
/**
* Set projet
*
* @param \AppBundle\Entity\Projet $projet
* @return Prototype
*/
public function setProjet(\AppBundle\Entity\Projet $projet = null)
{
$this->projet = $projet;
return $this;
}
/**
* Get projet
*
* @return \AppBundle\Entity\Projet
*/
public function getProjet()
{
return $this->projet;
}
}
我试过使用ModelManager()但是我得到了这个错误&#34;试图调用名为&#34; getModelManager&#34;的未定义方法。 class&#34; AppBundle \ Controller \ CRUDProtoController&#34;。 &#34; 我是奏鸣曲和symfony的新人,我发现它有困难。