Skip to content

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

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

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

Conversation

@jsirish
Copy link
Copy Markdown
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 ElementImage
  • Updated $singular_name from 'Image Element' to 'Image'
  • Updated $plural_name from 'Image Elements' to 'Image Blocks'

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

Related: dynamic/silverstripe-essentials-tools#68

Copilot AI review requested due to automatic review settings December 2, 2025 06:29
Copy link
Copy Markdown

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 refactors the ElementImage class to improve extensibility by removing the hardcoded getType() method override. Instead, it relies on the inherited BaseElement::getType() implementation which uses i18n_singular_name(), allowing sites to customize the element's display name through configuration or extensions.

Key Changes:

  • Removed the getType() method override to allow inheritance from BaseElement
  • Updated $singular_name from 'Image Element' to 'Image' to maintain the same display value
  • Updated $plural_name from 'Image Elements' to 'Image Blocks' for consistency with SilverStripe Elemental naming conventions

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

@jsirish jsirish merged commit 263c4e4 into 3 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.

2 participants