How to use it with Doctrine relations (both types: Associations and Embedded)? I have several problems with this feature.
src/FirstBundle/Entity/First.php
<?php
namespace FirstBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use SecondBundle\Entity\Second;
/**
* @ORM\Entity(repositoryClass="FirstBundle\Repository\First")
*/
class First
{
/** @ORM\Column(type="datetime") */
private $created_at;
/** @ORM\ManyToOne(targetEntity="SecondBundle\Entity\Second", fetch="EAGER") */
private $second;
public function getCreatedAt() : \DateTime { return $this->created_at; }
public function getSecond() : Second { return $this->second; }
}
src/FirstBundle/Entity/Embeddable/Contact.php
<?php
namespace FirstBundle\Entity\Embeddable;
use Doctrine\ORM\Mapping as ORM;
/** @ORM\Embeddable */
class Contact
{
/** @ORM\Column(type="string", length=190) */
private $city;
public function getCity() : string { return $this->city; }
}
src/SecondBundle/Entity/Second.php
<?php
namespace SecondBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="SecondBundle\Repository\Second")
*/
class Second
{
}
How to include Second entity as relationship with First entity? What i'm doin wrong? Connected with #20 i think but there is no solution provided for me.
WTF is with \DateTime and created_at field? How to format this as string? Connected with #21 but not working for me )-:
Why embeddable entity Contact has id field? Don't need this and doesn't have. It has stored just as contact_city field in first table. No PK exists.
Why embeddable entity Contact don't have city field?
Why id for First is string instead of integer (but it is in attributes).
If i remove EAGER loading of relation then i got error Closures are not supported in Serializer – how to fix this?
Why hide_properties is ignored for Second entity? Password must be excluded.
Hello.
How to use it with Doctrine relations (both types: Associations and Embedded)? I have several problems with this feature.
src/FirstBundle/Entity/First.php
src/FirstBundle/Entity/Embeddable/Contact.php
src/SecondBundle/Entity/Second.php
src/FirstBundle/Resources/config/mapping/first.yml
src/FirstBundle/Resources/config/mapping/contact.yml
src/SecondBundle/Resources/config/mapping/second.yml
After using this project like this
src/FirstBundle/Controller/First.php
I get very strange response:
Questions:
contact_city
field in first table. No PK exists.Closures are not supported in Serializer
– how to fix this?hide_properties
is ignored for Second entity? Password must be excluded.Thank you for your help.