I have a weird issue with Doctrine. I have set up the following structure:
/**
* @ORM\Entity
* @ORM\Table(name="fp_credit_returned_product")
*/
class ReturnedProduct {
...
/**
* @var FpCredit\Models\Credit\ReturnedProductDetail
* @ORM\OneToMany(targetEntity="\FpCredit\Models\Credit\ReturnedProductDetail", mappedBy="returned_product", cascade={"persist"})
*/
private $details;
public function getDetails() {
return $this->details;
}
public function setDetails($details) {
$this->details = $details;
}
and:
/**
* @ORM\Entity
* @ORM\Table(name="fp_credit_returned_product_detail")
*/
class ReturnedProductDetail {
/**
* @var FpCredit\Models\Credit\ReturnedProduct
* @ORM\ManyToOne(targetEntity="\FpCredit\Models\Credit\ReturnedProduct")
* @ORM\JoinColumn(name="returned_product_id", nullable=false, referencedColumnName="id")
*/
private $returnedProduct;
public function getReturnedProduct() {
return $this->returnedProduct;
}
public function setReturnedProduct($returnedProduct) {
$this->returnedProduct = $returnedProduct;
}
Then I query all returnedProducts and do the following:
foreach ($errorLogs as $eLog) {
$errorDetails = $eLog->getDetails();
if ($errorDetails) {
foreach ($errorDetails as $errorDetail) {
$errorArticle = $errorDetail->getArticle();
}
}
}
Because of the $errorDetail->getArticle()
I get this error:
PHP Fatal error: Call to a member function setValue() on null in /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/PersistentCollection.php
Does anybody know why this error occurs and how I can fix it? Is something wrong with my mapping? One ReturnedProducts has several ReturnProductDetails.
Thanks for your help!