- Issue created by @Chi
- π·πΊRussia Chi
Once π Allow parsing and writing PHP constants and enums in YAML files Needs work is resolved we could start using these constants in Yaml files
Currently plugin IDs are defined as string literals in plugin annotation/attributes. Any time you need to reference plugin you need to make sure you correctly type its ID.
Since we are converting plugin definitions to PHP attributes it should be possible to use PHP constants instead of string literals. I think this will ease refactoring and improve DX. No need to rely on phpstorm-meta for auto-completion.
#[FieldType(
id: self::ID,
label: new TM('Example'),
default_widget: ExampleWidget::ID,
default_formatter: ExampleFormatter::ID,
list_class: ExampleItemList::class,
)]
final class ExampleItem extends FieldItemBase {
public const string ID = 'example';
}
$fields['example'] = BaseFieldDefinition::create(Example::ID)
->setLabel(t('Example'))
->setDisplayOptions('form', ['type' => ExampleWidget::ID])
->setDisplayOptions('view', ['type' => ExampleFormatter::ID]);
Active
11.0 π₯
Last updated
Enhances developer experience.
Once π Allow parsing and writing PHP constants and enums in YAML files Needs work is resolved we could start using these constants in Yaml files