Gábor Hojtsy in #2235457-131: Use link field for shortcut entity:

+++ b/core/modules/shortcut/src/Entity/Shortcut.php
@@ -205,13 +146,22 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
+    $fields['link'] = BaseFieldDefinition::create('link')
+      ->setLabel(t('Path'))
+      ->setDescription(t('The location this shortcut points to.'))
+      ->setRequired(TRUE)
+      ->setTranslatable(FALSE)

It was discussed above that even though the link field has a title (and a description following #2413029: Change LinkItem schema to also store a description), that is not being used because the entity needs a label. Why is the field kept translatable then? Do we expect to support links different per language in a shortcut? The similar menu link patch at #2406749: Use a link field for custom menu link does not make the link field translatable.

Wim Leers in #2235457-135: Use link field for shortcut entity:

Why is the field kept translatable then? Do we expect to support links different per language in a shortcut?

But the code already says setTranslatable(FALSE) — so the link field isn't translatable.

Discussed with Gábor in chat. setTranslatable(FALSE) is the default. Hence it's opt-in, and he misread it precisely because it's opt-in: presence of a setTranslatable() call at all typically implies it's translatable.

So, rectifying that detail in #2415129: Small clean-up for Shortcut entity's usage of link field.

CommentFileSizeAuthor
#1 2415129-1.patch587 bytesWim Leers
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Issue summary: View changes
Issue tags: +Quickfix, +Trivial patch of the month, +D8MI
FileSize
587 bytes
hussainweb’s picture

Status: Needs review » Reviewed & tested by the community

Marking it as RTBC tentatively, after the discussion in #2235457: Use link field for shortcut entity as indicated in the Issue Summary.

plach’s picture

A non translatable base field definition will never be enabled for translation: is this the intended behavior? If we want to leave the possibility to have different paths per language it should be marked as translatable.

Gábor Hojtsy’s picture

@plach: The route name it replaced was also not translatable, so this is not much of a change.

amateescu’s picture

Status: Reviewed & tested by the community » Postponed

This cleanup could be a bit bigger based on the outcome of the title debate, so let's postpone it on whatever gets decided in #2406749: Use a link field for custom menu link.

Gábor Hojtsy’s picture

Status: Postponed » Reviewed & tested by the community

If the link field is to be used to store translations, that would be a MUCH bigger scale change, may have performance implications, etc. so I don't think removing this one line will hurt any such effort later. It will help readability of the code in the meantime.

plach’s picture

Works for me, I wasn't sure this solution was meant, after reading the previous comments.

amateescu’s picture

I didn't want to imply that this patch will hurt anything, just that we might want to re-purpose it for something bigger :)

  • webchick committed 887eea8 on 8.0.x
    Issue #2415129 by Wim Leers, Gábor Hojtsy: Small clean-up for Shortcut...
webchick’s picture

Status: Reviewed & tested by the community » Fixed

I think there's definitely a conversation to be had about how to handle translatability of these fields, but for now this seems like a simple clean-up.

Committed and pushed to 8.0.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.