Ho un problema con i mapping incoerenti. Nella mia applicazione ho due entità: contatto (entità con contatti ...) e informazioni, entità con informazioni su questo contatto (telefoni, e-mail, fax, siti Web, ecc.).I mapping sono incoerenti tra loro
e nella mia entità di contatto che ho fatto le variabili per ogni tipo, ne ho bisogno nella mia domanda perché in questo modo è molto più facile:
/**
* @ORM\OneToMany(targetEntity = "RelationInformations" , mappedBy = "objectID", cascade={"persist"})
*/
protected $contactInformations;
/**
* @ORM\OneToMany(targetEntity = "RelationInformations" , mappedBy = "objectID", cascade={"persist"})
*/
protected $contactPhone;
/**
* @ORM\OneToMany(targetEntity = "RelationInformations" , mappedBy = "objectID", cascade={"persist"})
*/
protected $contactFax;
/**
* @ORM\OneToMany(targetEntity = "RelationInformations" , mappedBy = "objectID", cascade={"persist"})
*/
protected $contactWebsite;
/**
* @ORM\OneToMany(targetEntity = "RelationInformations" , mappedBy = "objectID", cascade={"persist"})
*/
protected $contactEmail;
/**
* @ORM\OneToMany(targetEntity = "RelationInformations" , mappedBy = "objectID", cascade={"persist"})
*/
protected $contactCommunicator;
E per esempio getter per i telefoni assomiglia:
/**
* Get contactPhone
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getContactPhone()
{
if ($this->contactPhone !== null) {
foreach ($this->contactPhone->toArray() as &$info) {
if ($info->getType() !== RelationInformations::TYPE_TELEPHONE) {
$this->contactPhone->removeElement($info);
}
}
}
return $this->contactPhone;
}
In questo modo ho ottenuto solo i telefoni dalle mie informazioni solo utilizzando questa funzione, quindi è molto più semplice in altri posti dell'applicazione ottenere ciò che voglio.
RelationInformation Entity:
/**
* @var integer
* @ORM\Column(name = "rnis_id" , type = "integer" , nullable = false);
* @ORM\Id
* @ORM\GeneratedValue(strategy = "AUTO")
*/
private $id;
/**
* @var integer
* @ORM\ManyToOne(targetEntity = "RelationContact" , inversedBy = "contactInformations")
* @ORM\JoinColumn(name = "rnis_object_id" , referencedColumnName="rnct_id", nullable = false);
*/
private $objectID;
/**
* @var string
* @ORM\Column(name = "rnis_value" , type = "string" , nullable = false )
*/
private $value;
/**
* @var string
* @ORM\Column(name = "rnis_type" , type = "string" , nullable = false , length = 1)
*/
private $type;
/**
* @var boolean
* @ORM\Column(name = "rnis_active" , type = "boolean" , nullable = false)
*/
private $active;
/**
* @var boolean
* @ORM\Column(name = "rnis_default" , type = "boolean" , nullable = false)
*/
private $default;
/**
* @var string
* @ORM\Column(name = "rnis_txt" , type = "string" , nullable = true)
*/
private $txt;
/**
* @var integer
* @ORM\Column(name = "rnis_type_private_business" , type = "integer" , nullable = true)
*/
private $typePrivateBusiness;
Il problema è che nel mio profiler posso vedere errori come muggito. L'applicazione funziona correttamente ma voglio risolvere questo problema.
The mappings RelationContact#contactPhone and RelationInformations#objectID are inconsistent with each other.
The mappings RelationContact#contactFax and RelationInformations#objectID are inconsistent with each other.
The mappings RelationContact#contactWebsite and RelationInformations#objectID are inconsistent with each other.
The mappings RelationContact#contactEmail and RelationInformations#objectID are inconsistent with each other.
The mappings RelationContact#contactCommunicator and RelationInformations#objectID are inconsistent with each other.
The mappings RelationContact#contactBrand and RelationInformations#objectID are inconsistent with each other.
si prega di inviare il codice dell'Ente 'RelationInformations' – Matteo
Ok, ho aggiungerlo;) –