Details
Description
The creation of an Associated Collection of a Proxy Class is broken by this line:
$reflField->getValue($entity) ?: new ArrayCollection
$entity is a Proxy Class and the property is the field users. The function ReflectionProperty::getValue() will return an Entity User. This results that the internal collection of the PersistenCollection is an Entity. This results in:
Fatal error: Call to undefined method Entity\User::clear() in \library\Doctrine\ORM\PersistentCollection.php on line 206
This is my Entity Configuration
class Organization {
/**
* @OneToMany(targetEntity="User", mappedBy="organization", cascade={"persist", "remove"})
*/
private $users;
public function __constructor() {
$this->users = new ArrayCollection();
}
}
class User {
/**
* @ManyToOne(targetEntity="Organization", inversedBy="users")
* @JoinColumn(name="organization_id", referencedColumnName="id")
*/
private $organization;
}
Fixed formatting