Skip to content

REFACTOR: Remove getType() override to allow extensibility#21

Merged
jsirish merged 1 commit into2from
fix/remove-gettype-override
Dec 2, 2025
Merged

REFACTOR: Remove getType() override to allow extensibility#21
jsirish merged 1 commit into2from
fix/remove-gettype-override

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 ElementCard

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 #20

Related: dynamic/silverstripe-essentials-tools#68

Copilot AI review requested due to automatic review settings December 2, 2025 06:29
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 removes the getType() method override from ElementCard to improve extensibility. By inheriting BaseElement::getType(), sites can now customize the element's display name through the $singular_name configuration property rather than requiring method overrides.

Key Changes:

  • Removed hardcoded getType() method override that returned a static 'Card' translation
  • Element now inherits base implementation which uses the existing $singular_name property

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

@jsirish jsirish merged commit 041aceb into 2 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.

1 participant