- 🇬🇧United Kingdom joachim
Will it be able to work exactly like an entity reference field?
At the moment, the way the API work is that you can save entity data like this:
'title' => 'Some test data', 'type' => 'alpha', 'path' => ['alias' => '/one'],
and the path will get saved.
So it's not just a case of handling the path alias field widget differently -- the path alias field does magic at the API level too.
It should definitely behave like a *type* of entity field -- use EntityReferenceItemInterface/EntityReferenceItemBase and EntityReferenceFieldItemListInterface for one thing, and add the 'entity' computed property. But I think it will still to still be its own kind of reference field.
- 🇬🇧United Kingdom joachim
There's actually another, more important reason why this can't be a plain reference field: it works backwards compared to normal reference fields.
With a term reference, say, you do this when saving new entities:
1. Save the referenced term, so you get an ID for it
2. Set the ID as the reference field value
3. Save the referring nodeBut with path alias fields, it's the other way round. We have to have the ID of the referring node in order to get the system path to set in the path alias entity. So:
1. Save the referring node
2. Get its canonical path, /node/X
3. Save the path alias, with the canonical path and the alias given in the node's values