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 ElementTestimonials
  • Updated $singular_name from 'Testimonials Element' to 'Testimonials'
  • Updated $plural_name from 'Testimonials Elements' to 'Testimonials 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 #31

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 refactoring removes a hardcoded getType() method override to enable extensibility. By removing the override, the element now inherits BaseElement::getType() which retrieves the display name from i18n_singular_name(), allowing sites to customize the element's display name via extensions without overriding methods.

  • Removed hardcoded getType() method to leverage base class implementation
  • Updated $singular_name to 'Testimonials' to maintain consistent display name
  • Updated $plural_name to 'Testimonials Blocks' for list views

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

Comment on lines +32 to +37
private static $singular_name = 'Testimonials';

/**
* @var string
*/
private static $plural_name = 'Testimonials Elements';
private static $plural_name = 'Testimonials Blocks';
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

The singular and plural names appear inconsistent. If $singular_name is 'Testimonials' (already in plural form), then $plural_name should logically also be 'Testimonials' for consistency. Alternatively, consider $singular_name = 'Testimonials Block' and $plural_name = 'Testimonials Blocks' to follow standard singular/plural conventions where the plural adds an 's' to the singular form.

Copilot uses AI. Check for mistakes.
@jsirish jsirish merged commit 5f84f5d into master Dec 2, 2025
22 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