Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Follow-up to #1850080: Entity type labels lack plurality, cannot generate UI text based on label if plural is needed which added:
getSingularLabel()
getPluralLabel()
getCountLabel()
We also need to improve the documentation of:
label()
Proposed resolution
Add examples to the documentation so that developers know when to use each method.
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#27 | interdiff-17-27.txt | 793 bytes | gaurav.kapoor |
#27 | entitytypeinterface_label-2701005-27.patch | 4.56 KB | gaurav.kapoor |
#17 | interdiff-2701005-15-17.txt | 3.49 KB | brathbone |
#17 | entitytypeinterface_label-2701005-17.patch | 4.58 KB | brathbone |
#15 | entitytypeinterface_label-2701005-15.patch | 3.83 KB | brathbone |
Comments
Comment #2
alexpottI also think we should flesh out the change record with whatever we add here (https://www.drupal.org/node/2701005)
Comment #3
dawehnerThank you @alex to create the follow up
https://www.drupal.org/files/issues/interdiff_19999.txt already contains an interdiff for it.
Comment #4
alexpottFirst effort building on @dawehner's original work.
Comment #5
tstoecklerI thought so too, until I recently wanted to write a patch to auto-generate a collection route for entities. The problem is that the plural label as currently returned by the method is in fact lowercase, so it's not suitable for a page title of a page that lists entities.
So I guess we need another method :-/ not sure...
Comment #6
tstoecklerAt the very least the docs need to explain the situation better.
Comment #7
tstoecklerOpened #2767025: Add entity type label for a collection of entities for #5. #6 is still valid, IMHO, though.
Comment #8
kristiaanvandeneyndeMinor nitpick, but the descriptions aren't consistent at the moment.
This label
This label
I also agree with tstoeckler about the collection label.
Comment #9
xjmComment #11
xjmDiscussed with @alexpott, @cilefen, @fago, @Berdir, and @amateescu awhile back and we agreed this issue is not a major bug -- it looks like it was filed as such by accident.
Still an issue, though. Maybe a novice contributor could try to start addressing the recent feedback on the issue?
Comment #12
gianani CreditAttribution: gianani at Iksula commentedAdding patch. Tried to make the descriptions consistent.
Comment #13
tstoecklerI think this is a great start! I think it would be incredibly helpful to include an example usage with all of the methods, though. Not sure if others agree, so leaving at needs review.
Comment #15
brathbone CreditAttribution: brathbone as a volunteer commentedSince there has been a version change, the patch by @gianani (#12) did not apply so I did a partial apply and manually applied the rest. (First patch submitted to core here, so please let me know if this should be handled another way.)
As requested by @tstoeckler I added examples to getSingularLabe(), getPluralLabel(), and getCountLabel(). I also adjusted the descriptions in those functions to match the descriptions of the corresponding protected variables in EntityType.php.
Comment #16
tstoecklerThanks @brathbone for pushing this forward. I have some comments but I think we're pretty close, I really like the examples you added!
We should add docs for the new collection label, as well.
Thanks for adding this! It's not quite correct, though, I think. The singular label would be "opportunity" and not "Opportunity" (i.e lowercase).
I also think adding quotes will help make the text clearer.
Same as above, should be lowercase.
We should still have a one-line summary, although I agree that the current "count label" can definitely be improved.
Same as above, this should be lowercase as well.
Comment #17
brathbone CreditAttribution: brathbone as a volunteer commentedThanks to you, @tstoeckler, for the feedback. This new patch and interdiff contains the changes you requested:
-I added more documentation to getCollectionLabel(). I based this off of issue 2767025 and specifically the "Problem/Motivation" section.
-I adjusted all the examples to be lowercase and contained in quotation marks.
-I adjusted to the first line of the getCountLabel() documentation to fit into a single line.
Happy to adjust anything else.
Comment #18
yogeshmpawarComment #19
tstoecklerThanks a lot @brathbone, I think it reads very nicely now. You will save a lot of future developers from a lot of confusion with you work on this issue, this should not be underestimated! Very cool.
Comment #20
yogeshmpawarRTBC+1 from my side.
Comment #21
kristiaanvandeneyndeAnyone else seeing weird characters in the patch?
Comment #22
yogeshmpawar@kristiaanvandeneynde - No, we are not seeing these weird characters in this patch. we are seeing like this below mentioned.
Comment #23
tstoecklerOh, I didn't notice that you used actual proper quote characters. Not sure if that's allowed in in-code documentation. (Not saying that it's not, I genuinely don't know.) So moving back to needs review.
Comment #24
kristiaanvandeneyndeYeah they need to be double quotes. Any special character should -AFAIK- be HTML-encoded such as
“
and”
. Seeing as that can't be done in comments, those should be regular double quotes.Comment #25
kristiaanvandeneyndeComment #26
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs commentedComment #27
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs commentedComment #28
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs commentedComment #29
tstoecklerNice!
Comment #30
xjmThis should have the full namespace even though it's the same class (and no period). I've fixed this on commit.
Committed to 8.4.x. Since this is a documentation improvement, it's also eligible during the 8.3.x RC phase, so I've cherry-picked the patch to 8.3.x as well.
Comment #34
rajeevku CreditAttribution: rajeevku commented