When there was only one type of entity label, we had to use that in all places and transform it to the appropriate form. For example in our EntityDeriver plugins, we would generate an event called "Before saving @entity_type", and for @entity_type we had to use $entity_type->getLowercaseLabel() which is simply a lowercase version of our entity label.
But now we have label, label_singular, label_plural, label_count, and label_collection (see Entity types can specify plural labels now and Entity types can specify collection labels now)and now that Rules supports these various labels (see #2922889: Update entity label annotations) we can choose which one is best to use in our situation. In the above example, because we really intend for @entity_type to be the indefinite singular label it is better to use $entity_type->getSingularLabel().
In practice, getLowercaseLabel() and getSingularLabel() are identical with very few exceptions. The only difference I have noticed in Drupal core is for the 'node' entity, where the label is 'Content' so getLowercaseLabel() will return 'content' while getSingularLabel() will return 'content item'.
So the visible effect of this patch is that Node entity events such as "Before saving content" will now be "Before saving a content item". Although this is a small change, it should improve the wording for non-core entities as well. For example, with the "SMS Message" entity getLowercaseLabel() is "sms message" which is clearly not what we want - SMS is an acronym and should always be capitalized. Instead if we use getSingularLabel() it returns the correct "SMS message" in this case.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 2993612-3-singular-label.patch | 9 KB | tr |
| singular-label.patch | 5.03 KB | tr |
Comments
Comment #2
tr commentedComment #3
tr commentedForgot to update the test text for the new singular labels. Here's a new patch with the modified tests.
Comment #5
tr commentedCommitted.