-
Notifications
You must be signed in to change notification settings - Fork 3
Description
- Version:
develop
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
Routefor the current entity (MenuElement, or ratherMenuElementInstitin my case) and create a reflection entity - we then loop on the route parameters (in my case, for
MenuElementInstit, it's justslug), get the reflection property for each one from the reflection entity - for each annotation on
$slug, we look for thetargetEntityproperty...
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.