Mam problem z niespójnymi odwzorowaniami. Mam w mojej aplikacji dwie jednostki - Kontakt (podmiot z kontaktami ...) oraz Informacje, podmioty z informacjami do tego kontaktu (telefony, e-maile, faksy, strony internetowe itp.).Mapowania są niezgodne ze sobą
i moim podmiot kontaktowy zrobiłem zmiennych dla każdego typu, muszę go w mojej aplikacji, ponieważ w ten sposób jest dużo łatwiejsze:
/**
* @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;
i przykładowo getter dla telefonów wygląda następująco:
/**
* 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;
}
W ten sposób mam tylko telefony z moich informacji tylko za pomocą tej funkcji, więc jest to znacznie łatwiejsze w innych miejscach w aplikacji, aby uzyskać to, co chcę.
RelationInformation Podmiot:
/**
* @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;
Problemem jest to, że w moim profiler widzę błędy jak mieszka. Aplikacja działa poprawnie, ale chcę rozwiązać ten problem.
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.
proszę pisać kod podmiotu 'RelationInformations' – Matteo
Ok, muszę dodać go;) –