md-systems / redirect

DEPRECATED: Redirect moved back to drupal.org, use the official repository.
https://www.drupal.org/project/redirect
21 stars 29 forks source link

A reason for the field not extending EntityReference? #69

Closed janstoeckler closed 8 years ago

janstoeckler commented 8 years ago

Hello all, is there a particular architectural reason for the field not extending EntityReference? I'm currently working on adding some logic to the provided field (https://github.com/janstoeckler/redirect/tree/field-enhancement) and was thinking about possibly using Entity Reference instead of extending FieltItemBase.

Are there any pros or cons I might be missing?

Berdir commented 8 years ago

Uhm, a reference to what exactly? It's just a path, there is no reference to something else?

janstoeckler commented 8 years ago

I was thinking to the Redirect entity?

Berdir commented 8 years ago

We are the redirect entity, we can't reference ourself?

janstoeckler commented 8 years ago

I may be misunderstanding the way \Drupal\redirect\Plugin\Field\FieldType\RedirectSourceItem is supposed to be used. I was under the (possibly mistaken) impression that field was provided so it could be added to content entities for adding redirects from the comfort of the /{entity-type}/edit page in addition to the global redirect configuration page. To that end, I intend to "add"/create non-existing Redirect entities in that same context, a task that could be simplified if the RedirectSourceItem-field was to extend EntityReference.

Maybe, very possibly, I'm just entirely missing how this module is supposed to work.

Berdir commented 8 years ago

No, it has nothing to do with that :)

It's a field that the redirect entity itself uses to store the source path of the redirect. It's not meant to be used elsewhere.

We should add a no_ui = TRUE flag to the annotation.

janstoeckler commented 8 years ago

Ah, that makes sense. Would you be interested in such a field (addable to entities) as part of this module, though?

Berdir commented 8 years ago

Not sure, what exactly would that do as opposed to a normal entity reference? Does it actually need to be referenced or could you just have a UI component that displays redirects that are related to an entity based on the destination path?