Skip to content

Commit 454f741

Browse files
authored
Fix Doctrine mapping errors (#157)
* Add missing inversedBy setting and use ProductInterface as traget entity * Extract $validator property of the trait due to different inversedBy config * Add validator changes to Upgrade doc
1 parent 5b69cad commit 454f741

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

UPGRADE-4.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
- Doctrine entities have been updated to use Attributes instead of XML mappings.
44
- The bundle no longer includes migrations. These should be generated in your project.
5+
- When implementing a custom validator constraint or condition, your class needs to have $validator property incl. Doctrine metadata

src/Entity/CustomerOptions/CustomerOptionValuePrice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class CustomerOptionValuePrice implements CustomerOptionValuePriceInterface, \St
4343
#[ORM\JoinColumn(onDelete: 'CASCADE')]
4444
protected ?CustomerOptionValueInterface $customerOptionValue = null;
4545

46-
#[ORM\ManyToOne(targetEntity: ChannelInterface::class)]
46+
#[ORM\ManyToOne(targetEntity: ProductInterface::class, inversedBy: 'customerOptionValuePrices')]
4747
#[ORM\JoinColumn(onDelete: 'CASCADE')]
4848
protected ?ProductInterface $product = null;
4949

src/Entity/CustomerOptions/Validator/Condition.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ class Condition implements ConditionInterface
1313
{
1414
use ConditionTrait;
1515

16+
#[ORM\ManyToOne(targetEntity: ValidatorInterface::class, cascade: ['persist'], inversedBy: 'conditions')]
17+
#[ORM\JoinColumn(onDelete: 'CASCADE')]
18+
protected ?ValidatorInterface $validator = null;
19+
1620
#[ORM\Id]
1721
#[ORM\GeneratedValue]
1822
#[ORM\Column(type: 'integer')]

src/Entity/CustomerOptions/Validator/Constraint.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ class Constraint implements ConstraintInterface
1313
{
1414
use ConditionTrait;
1515

16+
#[ORM\ManyToOne(targetEntity: ValidatorInterface::class, cascade: ['persist'], inversedBy: 'constraints')]
17+
#[ORM\JoinColumn(onDelete: 'CASCADE')]
18+
protected ?ValidatorInterface $validator = null;
19+
1620
#[ORM\Id]
1721
#[ORM\GeneratedValue]
1822
#[ORM\Column(type: 'integer')]

src/Traits/ConditionTrait.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ trait ConditionTrait
2424
#[ORM\Column(type: 'json', nullable: true)]
2525
protected ?array $value = null;
2626

27-
#[ORM\ManyToOne(targetEntity: ValidatorInterface::class, cascade: ['persist'], inversedBy: 'conditions')]
28-
#[ORM\JoinColumn(onDelete: 'CASCADE')]
29-
protected ?ValidatorInterface $validator = null;
30-
3127
/** @inheritdoc */
3228
public function getCustomerOption(): ?CustomerOptionInterface
3329
{

0 commit comments

Comments
 (0)