Closed
Description
Symfony version(s) affected: 4.3.x
Description
#31775 tackled the issue and #31811 solved it when embedded object does not have an embedded object in it self. The problem still remains when f.e. embedded object is in embedded object in entity.
How to reproduce
Entities
<?php
declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Embeddable()
*/
class Currency
{
/**
* @var string
*
* @ORM\Column(name="code", type="string", length=3)
*/
protected $code;
public function __construct(string $code)
{
$this->code = $code;
}
public function getCode(): string
{
return $this->code;
}
}
<?php
declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Embeddable()
*/
class Money
{
/**
* @var string
*
* @ORM\Column(name="amount", type="string", length=255)
*/
protected $amount;
/**
* @var Currency
*
* @ORM\Embedded(class="App\Entity\Currency")
*/
protected $currency;
public function __construct(string $amount, Currency $currency)
{
$this->amount = $amount;
$this->currency = $currency;
}
public function getAmount(): string
{
return $this->amount;
}
public function setAmount(string $amount): void
{
$this->amount = $amount;
}
public function getCurrency(): Currency
{
return $this->currency;
}
}
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\ProductRepository")
*/
class Product
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
protected $id;
/**
* @var Money
*
* @ORM\Embedded(class="App\Entity\Money")
*/
protected $price;
public function getId(): ?int
{
return $this->id;
}
}
and if tried to use validator on entity Product
In PropertyMetadata.php line 40:
Property "price.currency" does not exist in class "App\Entity\Product"
Problem lays here