Allow relationship overriding #6361

Open
opened 2026-01-22 15:31:44 +01:00 by admin · 2 comments
Owner

Originally created by @tom10271 on GitHub (Dec 4, 2019).

Feature Request

Q A
New Feature yes
RFC no
BC Break no

Summary

I was using Sylius 1.6 adn want to set cascade={"persist"} by

<?php

declare(strict_types=1);

namespace App\Entity\Product;

use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\ProductTaxon as BaseProductTaxon;
use Sylius\Component\Core\Model\TaxonInterface;

/**
 * @ORM\Entity
 * @ORM\Table(name="sylius_product_taxon")
 */
class ProductTaxon extends BaseProductTaxon
{
    /**
     * @ORM\ManyToOne(targetEntity="App\Entity\Taxonomy/Taxon", cascade={"persist"})
     * @ORM\JoinColumn(name="taxon_id", referencedColumnName="id", nullable=true)
     * @var TaxonInterface
     */
    protected $taxon;
}

Turns out it will not work and I found there are AssociationOverrides and AttributeOverrides. After checking there is will no way to add cascade={"persist"} into relationship setting, it is troublesome to setup a event listener and override there, although it seems I have no choice.

Originally created by @tom10271 on GitHub (Dec 4, 2019). ### Feature Request <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | New Feature | yes | RFC | no | BC Break | no #### Summary <!-- Provide a summary of the feature you would like to see implemented. --> I was using Sylius 1.6 adn want to set `cascade={"persist"}` by ```php <?php declare(strict_types=1); namespace App\Entity\Product; use Doctrine\ORM\Mapping as ORM; use Sylius\Component\Core\Model\ProductTaxon as BaseProductTaxon; use Sylius\Component\Core\Model\TaxonInterface; /** * @ORM\Entity * @ORM\Table(name="sylius_product_taxon") */ class ProductTaxon extends BaseProductTaxon { /** * @ORM\ManyToOne(targetEntity="App\Entity\Taxonomy/Taxon", cascade={"persist"}) * @ORM\JoinColumn(name="taxon_id", referencedColumnName="id", nullable=true) * @var TaxonInterface */ protected $taxon; } ``` Turns out it will not work and I found there are `AssociationOverrides` and `AttributeOverrides`. After checking there is will no way to add `cascade={"persist"}` into relationship setting, it is troublesome to setup a event listener and override there, although it seems I have no choice.
Author
Owner

@SenseException commented on GitHub (Dec 8, 2019):

Hi @tom10271, are those overrides in the base class of Sylius or in the custom ProductTaxon?

@SenseException commented on GitHub (Dec 8, 2019): Hi @tom10271, are those overrides in the base class of Sylius or in the custom `ProductTaxon`?
Author
Owner

@andreo-code commented on GitHub (Apr 21, 2021):

Up.The cascade property in doctrine cannot be overridden

@andreo-code commented on GitHub (Apr 21, 2021): Up.The cascade property in doctrine cannot be overridden
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6361