1
我试图让一个平滑的管理界面相似,如果两个实体通过多对多关系相关联。我需要连接表来定义像rank这样的附加信息。我不想在后端显示可连接的实体,它应该可写入至少一个实体的编辑菜单中。我的例子:许多许多与EasyAdminBundle加入表
class Question{
/**
* @Assert\NotBlank()
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Options2Questions", mappedBy="question", cascade={"persist"})
*/
private $optionQuestion;
public function __construct() {
$this->optionQuestion = new \Doctrine\Common\Collections\ArrayCollection();
}
public function addOptionQuestion(\AppBundle\Entity\Options2Questions $optionQuestion){
$this->optionQuestion[] = $optionQuestion;
return $this;
}
public function removeOptionQuestion(\AppBundle\Entity\Options2Questions $optionQuestion){
$this->optionQuestion->removeElement($optionQuestion);
}
public function getOptionQuestion(){
return $this->optionQuestion;
}
}
class Options{
/**
* @Assert\NotBlank()
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Options2Questions", mappedBy="options")
*/
private $optionQuestion;
public function __construct(){
$this->optionQuestion = new \Doctrine\Common\Collections\ArrayCollection();
}
public function addOptionQuestion(\AppBundle\Entity\Options2Questions $optionQuestion){
$this->optionQuestion[] = $optionQuestion;
return $this;
}
public function removeOptionQuestion(\AppBundle\Entity\Options2Questions $optionQuestion)
{
$this->optionQuestion->removeElement($optionQuestion);
}
public function getOptionQuestion(){
return $this->optionQuestion;
}
}
class Options2Questions
{
/**
* @ORM\Id()
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Options", inversedBy="optionsQuestions")
* @ORM\JoinColumn(name="options_id", referencedColumnName="id", nullable=false)
*/
private $options;
/**
* @ORM\Id()
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Question", inversedBy="optionsQuestions")
* @ORM\JoinColumn(name="question_id", referencedColumnName="id", nullable=false)
*/
private $question;
/**
* @var int
*
* @ORM\Column(name="rank", type="integer", nullable=true)
*/
private $rank;
/**
* Set rank
*
* @param integer $rank
*
* @return Options2Questions
*/
public function setRank($rank)
{
$this->rank = $rank;
return $this;
}
/**
* Get rank
*
* @return int
*/
public function getRank()
{
return $this->rank;
}
/**
* Set options
*
* @param \AppBundle\Entity\Options $options
*
* @return Options2Questions
*/
public function setOptions(\AppBundle\Entity\Options $options)
{
$this->options = $options;
return $this;
}
/**
* Get options
*
* @return \AppBundle\Entity\Options
*/
public function getOptions()
{
return $this->options;
}
/**
* Set question
*
* @param \AppBundle\Entity\Question $question
*
* @return Options2Questions
*/
public function setQuestion(\AppBundle\Entity\Question $question)
{
$this->question = $question;
return $this;
}
/**
* Get question
*
* @return \AppBundle\Entity\Question
*/
public function getQuestion()
{
return $this->question;
}
}
我在这找不到任何文档。我应该在哪里具体看?
你确定这将与easyadminbundle工作?这对我来说似乎是一个奏鸣曲的东西 – Jeff
是的,我没有看到关于标题中的EasyAdmin。但是,这个想法应该是一样的。 – staskrak