Asi como lo dices lo he hecho, creo que debí ser mas explicito:
Código PHP:
$relationship = $this->emMy->getRepository('ABCIsystemBundle:AbcRelationship')->findOneBy(array('relationshipEn'=>'Mother'));
$membersContacts = new AbcMembersContacts();
$membersContacts->setMember($student->getMember());
$membersContacts->setContact($parent->getMember());
$membersContacts->getRelationship($relationship);
$membersContacts->setMainContact('f');
$membersContacts->setContactOrder(2);
$this->emMy->persist($membersContacts);
$this->emMy->flush();
Entidad AbcMembersContacts:
Código PHP:
<?php
namespace ABCIsystemBundleEntity;
use DoctrineORMMapping as ORM;
/**
* AbcMembersContacts
*
* @ORM\Table(name="abc_members_contacts")
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="ABC\IsystemBundle\Repository\AbcMembersContactsRepository")
*/
class AbcMembersContacts
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="main_contact", type="string", nullable=false)
*/
private $mainContact;
/**
* @var \AbcMembers
*
* @ORM\ManyToOne(targetEntity="AbcMembers", inversedBy="contacts", cascade={"persist"})
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="member", referencedColumnName="id")
* })
*/
private $member;
/**
* @var \AbcMembers
*
* @ORM\ManyToOne(targetEntity="AbcMembers", inversedBy="contactsm", cascade={"persist"})
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="contact", referencedColumnName="id")
* })
*/
private $contact;
/**
* @var \AbcRelationship
*
* @ORM\ManyToOne(targetEntity="AbcRelationship", cascade={"persist"})
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="relationship", referencedColumnName="id")
* })
*/
private $relationship;
/**
* @var \DateTime
*
* @ORM\Column(name="created_date", type="datetime", nullable=false)
*/
private $createdDate;
/**
* @var integer
* @ORM\Column(name="contact_order", type="integer", nullable=true)
*/
private $contactOrder;
/**
* @ORM\OneToOne(targetEntity="\ABC\PreEnrollmentBundle\Entity\EnrollPayers", mappedBy="memberContact", cascade={"persist", "remove"})
*/
protected $payer;
public function setPayer(ABCPreEnrollmentBundleEntityEnrollPayers $payer = null)
{
$this->payer = $payer;
$payer->setMemberContact($this);
return $this;
}
public function getPayer(){
return $this->payer;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set mainContact
*
* @param string $mainContact
* @return AbcMembersContacts
*/
public function setMainContact($mainContact)
{
$this->mainContact = $mainContact;
return $this;
}
/**
* Get mainContact
*
* @return string
*/
public function getMainContact()
{
return $this->mainContact;
}
/**
* Set member
*
* @param \ABC\IsystemBundle\Entity\AbcMembers $member
* @return AbcMembersContacts
*/
public function setMember(ABCIsystemBundleEntityAbcMembers $member)
{
$this->member = $member;
return $this;
}
/**
* Get member
*
* @return \ABC\IsystemBundle\Entity\AbcMembers
*/
public function getMember()
{
return $this->member;
}
/**
* Set contact
*
* @param \ABC\IsystemBundle\Entity\AbcMembers $contact
* @return AbcMembersContacts
*/
public function setContact(ABCIsystemBundleEntityAbcMembers $contact)
{
$this->contact = $contact;
return $this;
}
/**
* Get contact
*
* @return \ABC\IsystemBundle\Entity\AbcMembers
*/
public function getContact()
{
return $this->contact;
}
/**
* Set relationship
*
* @param \ABC\IsystemBundle\Entity\AbcRelationship $relationship
* @return AbcMembersContacts
*/
public function setRelationship(ABCIsystemBundleEntityAbcRelationship $relationship = null)
{
$this->relationship = $relationship;
return $this;
}
/**
* Get relationship
*
* @return \ABC\IsystemBundle\Entity\AbcRelationship
*/
public function getRelationship()
{
return $this->relationship;
}
/**
* @ORM\PrePersist
*/
public function setCreatedDateValue()
{
$this->createdDate = new DateTime();
}
/**
* Set createdDate
*
* @param \DateTime $createdDate
* @return AbcMembers
*/
public function setCreatedDate($createdDate)
{
$this->createdDate = $createdDate;
return $this;
}
/**
* Get createdDate
*
* @return \DateTime
*/
public function getCreatedDate()
{
return $this->createdDate;
}
/**
* Set academicOrder
*
* @param integer $order
* @return AbcMembersContacts
*/
public function setContactOrder($order)
{
$this->contactOrder = $order;
return $this;
}
/**
* Get order
*
* @return integer
*/
public function getContactOrder()
{
return $this->contactOrder;
}
}