I have these two entities, with a ManyToOne relationship, bidirectionnal:
/**
* @ORM\Entity(repositoryClass=MenuElementRepository::class)
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="site", type="string")
* @ORM\DiscriminatorMap({
* "site_instit" = "MenuElementInstit",
* "site_loc" = "MenuElementLoc"
* })
*/
abstract class MenuElement implements RoutableModelInterface, HistorizableUrlModelInterface, HasSeoMetadataInterface
{
use HistorizableUrlTrait, SeoMetadataTrait;
/**
* @ORM\OneToMany(targetEntity=Page::class, mappedBy="menuElement")
*/
private $pages;
/**
* @ORM\Column(type="string", length=255)
*/
protected $slug;
...
}
/**
* @ORM\Entity(repositoryClass=PageRepository::class)
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="site", type="string")
* @ORM\DiscriminatorMap({
* "site_instit" = "PageInstit",
* "site_prog" = "PageProg",
* "site_loc" = "PageLoc"
* })
*/
abstract class Page implements RoutableModelInterface, HistorizableUrlModelInterface, HasSeoMetadataInterface
{
use HistorizableUrlTrait, SeoMetadataTrait;
/**
* @ORM\ManyToOne(targetEntity=MenuElement::class, inversedBy="pages")
*/
private $menuElement;
/**
* @ORM\Column(type="string", length=255)
*/
protected $slug;
...
}
The route scheme for Page is /{menuElement.slug}/{slug} (and just /{slug} for MenuElement). So, when I modify the $slug on a MenuElement instance, I need a redirection to be added to umanit_seo_url_history for both my MenuElement and the Pages linked to it.
I've looked at the UrlHistoryWriter->postLoad() method that adds entities related to the entity being updated to the cache, to allow historization of dependencies on onFlush event and I'm not quite sure the way it's written now allows it to work.
From what I gather, using my example:
- we get the
Route for the current entity (MenuElement, or rather MenuElementInstit in my case) and create a reflection entity
- we then loop on the route parameters (in my case, for
MenuElementInstit, it's just slug), get the reflection property for each one from the reflection entity
- for each annotation on
$slug, we look for the targetEntity property...
Which $slug doesn't have, because the targetEntity is on the $pages property.
I'm not sure why we are looking for a dependency through the route parameters.
developI have these two entities, with a
ManyToOnerelationship, bidirectionnal:The route scheme for
Pageis/{menuElement.slug}/{slug}(and just/{slug}forMenuElement). So, when I modify the$slugon aMenuElementinstance, I need a redirection to be added toumanit_seo_url_historyfor both myMenuElementand thePageslinked to it.I've looked at the
UrlHistoryWriter->postLoad()method that adds entities related to the entity being updated to the cache, to allow historization of dependencies ononFlushevent and I'm not quite sure the way it's written now allows it to work.From what I gather, using my example:
Routefor the current entity (MenuElement, or ratherMenuElementInstitin my case) and create a reflection entityMenuElementInstit, it's justslug), get the reflection property for each one from the reflection entity$slug, we look for thetargetEntityproperty...Which
$slugdoesn't have, because thetargetEntityis on the$pagesproperty.I'm not sure why we are looking for a dependency through the route parameters.