There is a method on DataObject which returns a 'best guess' plural name of you data object, see - http://api.silverstripe.org/3.0/source-class-DataObject.html#659-676
$name = $this->singular_name();
if(substr($name,-1) == 'e') $name = substr($name,0,-1);
else if(substr($name,-1) == 'y') $name = substr($name,0,-1) . 'ie';
return ucfirst($name . 's');
This is used by GridFields 'Link Existing' auto completer. I am confused by the nested if() in this method. I understand the purpose of truncating a 'y' and replacing with 'ies' e.g. Party -> Parties etc.
The first part of the if() checks to see if the name ends with 'e', if so it truncates it (and then proceeds to make it plural by adding 's')!
I cannot think of any good reason for this? Perhaps I am missing something but I do not see why this line of code exists? It is returning 'Carousel Slids' instread of 'Carousel Slides' for one of my data objects. Other incorrect examples it would return include:
- Tree = Tres
- Page = Pags
- Attribute = Attributs
I know I can solve this issue by adding a 'private static $plural_name = "Carousel Slides";' on my data object, but thats not the point, I am trying to understand if there is any logical reason for this line of code, or if it should be marked as a bug?
Any suggestions appreciated.