Doublecheck CustomElementsFieldFormatterBase::getSetting()

Created on 15 August 2024, 5 months ago
Updated 11 September 2024, 4 months ago

Problem/Motivation

CustomElementsFieldFormatterBase::getSetting() points into $this->configuration['settings']

But we (by which I mean: any formatters that are not wrapping Core Field formatters) are not using the 'settings' sub-array. So this is both bogus and confusing.

Intent

Not necessarily be perfect, but be harder to inadvertently call the wrong method, for people creating CeFieldFormatters.

Proposed resolution

EDIT: This has turned out to be unnecessary, because CustomElementsFieldFormatterBase::getSetting() is not used by Core Field formatters at all. We can therefore just fix the "confusing" part, by removing ['settings'] from the getSetting() code.

Separate but related

EDIT: default config is already being merged early. The problem is, we have defaultConfiguration() which is being merged, and defaultSettings() which isn't. This should be fixed by better code comments.

📌 Task
Status

Fixed

Version

3.0

Component

Code

Created by

🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @roderik
  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU
  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU
  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

    Dumping draft comments I jotted down somewhere, to check at the same time. Not fixing for understandability - I will likely be the one to look at this anyway.

    - take CoreFieldCeFieldFormatter
      - check buildConfigurationForm() & settingsForm().
      - what is what?						<-- settingsForm() is never used
      - when you understand that: fix the fact that CustomElementsFieldFormatterBase::settingsForm() / settingsSummary() have no definition in an interface AND STILL have @inheritdoc
        - then document that, in settingsform() (????), you should not use 'field_definition', 'view_mode', 'name', 'is_slot' -- because they will not be used.
    
  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

    Better comments for myself / later reference (I will be able to find them back):

    g/setSetting(s)() + static defaultSettings() are from PluginSettingsInterface

    g/setConfiguration() + non-static defaultConfiguration() are from ConfigurableInterface

    settingsForm() & settingsSummary() are not in an interface. Core field formatters have them in FormatterInterface but we don't implement that.

    settingsForm() is not used anywhere, can be deleted. settingsSummary() we should probably add to CustomElementsFieldFormatterInterface. (We've done the same with static isApplicable() which ia also in FormatterInterface.)

    build/validate/submitConfigurationForm() are from PluginFormInterface

    There's a Core issue to merge PluginSettingsInterface into ConfigurableInterface ( #1764380: Merge PluginSettingsInterface into ConfigurableInterface ) but it isn't going anywhere. (If that is ever done, I assume all "*Setting*" names will be deprecated.)

    The only reason why we implement PluginSettingsInterface, seems to be that EntityDisplayInterface:getRenderer()'s return value requires it. Otherwise we would not have these duplicate methods.

    We could have chosen to not implement ConfigurableInterface instead, but we didn't. (Also PluginSettingsInterface::defaultSettings() is more clunky because static.)

  • Merge request !90Tweak CEFieldFormatterBase + interface → (Merged) created by roderik
  • Assigned to fago
  • Status changed to Needs review 4 months ago
  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

    @fago for review, as this is a basic change to your code.

  • 🇦🇹Austria fago Vienna

    Thank you, this seems gresat! This improves things largely and will definitely help to avoid (further) confusion.

  • Pipeline finished with Skipped
    4 months ago
    #279780
    • fago committed e3fa03ab on 3.x authored by roderik
      Issue #3468343 by roderik: Doublecheck CustomElementsFieldFormatterBase...
  • Status changed to Fixed 4 months ago
  • 🇦🇹Austria fago Vienna
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024