- Issue created by @just_like_good_vibes
- Merge request !353Issue #3513568 by just_like_good_vibes: Source usability : better interfaces for sources relying on child plugins β (Open) created by just_like_good_vibes
- π«π·France pdureau Paris
I am not sure about the naming...
Proposal inspired from [ObjectWithPluginCollectionInterface](https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Plugin%21...) but not identical because we have a single collection and not many collections:
interface SourceWithCollectionInterface { /** * Get collection of items. * * @return array * Array of items definitions. */ public function getCollection(): array; /** * Get the minimal source configuration for an item. * * @param string $item_id * An item ID. * * @return array * A source configuration. */ public function getSourceConfiguration(string $item_id): array; /** * Get the currently select item from the collection. * * @return string|null * The item ID. */ public function getSelectedItem(): ?string;
Do we also need a
getItemLabel(string $item_id): string
? - π«π·France just_like_good_vibes PARIS
getMinimalConfiguration does not need any parameter, unless it is static, which could be a nice idea after all.
i donβt like collection, because it reminds of the plugin collections in drupal which are managed differentlyβ¦
- π«π·France just_like_good_vibes PARIS
also, the term configuration for the source refers to the global configuration, whereas we wanted the settings, i would keep settings to avoid confusion
- π«π·France pdureau Paris
getMinimalConfiguration does not need any parameter, unless it is static, which could be a nice idea after all.
Oops, a copy paste mistake, I fix it in my comment
- π«π·France pdureau Paris
- getChildPluginDefinitions >> getItems
- getSettingsSourceWithChildPlugin >> getMinimalSetting
- getChildPluginId >>getSelectedItem
interface SourceWithItemsInterface { /** * Get items. * * @return array * Associative array of items definitions with ID as the key. */ public function getItems(): array; /** * Get the minimal settings for an item. * * @param string $item_id * An item ID. * * @return array * A source setting. */ public function getMinimalSetting(string $item_id): array; /** * Get the currently select item. * * @return string|null * The item ID. */ public function getSelectedItem(): ?string;
Is it better?
Also:
- Do we also need a getItemLabel(string $item_id): string ?
- it may be good to move ::getMinimalSetting() to SourceInterface and to implemtn it in SourcePluginBase as a proxy to PluginSettingsInterface::defaultSettings(). What do you think?
- π«π·France just_like_good_vibes PARIS
i am not so fan of items neither :)