-
-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
Update getType() to allow site-specific customization via extensions.
Current Implementation
public function getType()
{
return _t(__CLASS__ . '.BlockType', 'Testimonials');
}Proposed Change
Remove the getType() override entirely. The base BaseElement::getType() already uses $this->i18n_singular_name() which respects $singular_name:
// BaseElement::getType() - already does the right thing
public function getType()
{
$default = $this->i18n_singular_name() ?: 'Block';
return _t(static::class . '.BlockType', $default);
}By removing the override, the element will inherit this behavior and allow sites to customize the display name via extensions by simply setting $singular_name.
Rationale
This pattern allows sites using these elements to customize the display name in the CMS element picker by simply setting $singular_name via an extension, rather than having to override the entire getType() method (which is not possible via extensions since PHP calls the class method directly, bypassing __call()).
Related: dynamic/silverstripe-essentials-tools#68
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request