Follow-up of #2224761: Add a generic way to add third party configuration on configuration entities and implement for field configuration.

Problem/Motivation

Since FieldInstanceConfig extends FieldConfigBase, and FieldConfigBase uses ThirdPartySettingsTrait, instances of FieldInstanceConfig can be expected to provide the ThirdPartySettings-related methods. (I'm still a bit inexperienced with this OOP stuff, so bear with me please...) If I understand correctly, it would make sense if FieldInstanceConfigInterface extends ThirdPartySettingsInterface, so other implementations of FieldInstanceConfigInterface must support third party settings too.

As a bonus, implementing ThirdPartySettingsInterface would allow variable type hinting on the FieldInstanceConfigInterface like this (thus enabling code completion in IDE's like PhpStorm):

use Drupal\field\Entity\FieldInstanceConfig;

/** @var \Drupal\field\FieldInstanceConfigInterface $config */ 
$config = FieldInstanceConfig::load('some.config.id');
$config->getThirdPartySetting('module', 'key', array()); // Typing "getT" in PhpStorm makes the IDE suggest this method.

Proposed resolution

Let FieldInstanceConfigInterface extend ThirdPartySettingsInterface.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

marcvangend’s picture

Assigned: marcvangend » Unassigned
Status: Active » Needs review
FileSize
846 bytes

...and the patch.

Xano’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Postponed

I think this interface should extend \Drupal\Core\Field\FieldConfigInterface - I also think we should postpone this on #2312093: Rename FieldInstanceConfig to FieldConfig since this will conflict we'll have some naming issues in this issue to sort out after.

marcvangend’s picture

Status: Postponed » Needs work

OK, FieldInstanceConfig has been renamed to FieldConfig, but I'm not quite sure what the correct fix is now. Alex, can you help me understand the logic to decide who should be extending who?

swentel’s picture

Berdir’s picture

Status: Needs work » Closed (duplicate)