Skip to content

Conversation

@jsirish
Copy link
Member

@jsirish jsirish commented Dec 2, 2025

Summary

Remove the getType() method override so the element inherits BaseElement::getType() which uses i18n_singular_name(). This allows sites to customize the element's display name via extensions by setting $singular_name.

Changes

  • Removed the getType() method from ElementAccordion

Rationale

The base BaseElement::getType() implementation already uses $this->i18n_singular_name():

public function getType()
{
    $default = $this->i18n_singular_name() ?: 'Block';
    return _t(static::class . '.BlockType', $default);
}

By removing the override, extensions can now customize the display name in the CMS element picker by simply setting $singular_name, without needing to override the entire method.

Fixes #54

Related: dynamic/silverstripe-essentials-tools#68

Remove the getType() method override so the element inherits
BaseElement::getType() which uses i18n_singular_name(). This allows
sites to customize the element's display name via extensions by
setting $singular_name.

Fixes #54
Copilot AI review requested due to automatic review settings December 2, 2025 06:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves extensibility by removing a method override that prevented customization of the element's display name. The removed getType() method is replaced by inheriting the base implementation from BaseElement, which supports customization via the $singular_name property.

  • Removed hardcoded getType() method override from ElementAccordion
  • Enables extensions to customize the element's display name by setting $singular_name
  • Maintains existing behavior through the BlockType translation key in lang/en.yml

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jsirish jsirish merged commit 8f4218f into 5 Dec 2, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update getType() to use $this->singular_name() for extensibility

2 participants