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.
API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21...
> Returns the bundle information for the specified entity type
This needs to say what form that information takes. It appears to be an array of bundle ID => bundle label.
Comment | File | Size | Author |
---|---|---|---|
#28 | interdiff-2720077-25-28.txt | 1.44 KB | Vinay15 |
#28 | 2720077-28.patch | 1.22 KB | Vinay15 |
#25 | interdiff-2720077-20-25.txt | 2.91 KB | Vinay15 |
#25 | 2720077-25.patch | 1.1 KB | Vinay15 |
#20 | adding_description-20.patch | 2.86 KB | rajeshwari10 |
Comments
Comment #2
joachim CreditAttribution: joachim as a volunteer commentedComment #3
leolandotan CreditAttribution: leolandotan as a volunteer and at Promet Source commentedI'll try to work on this.
Comment #4
skowyra CreditAttribution: skowyra commentedI'm looking into this at DrupalCon NOLA
Comment #5
Sonal.Sangale CreditAttribution: Sonal.Sangale at Blisstering Solutions commentedComment #6
Sonal.Sangale CreditAttribution: Sonal.Sangale at Blisstering Solutions commentedAdding description.
Comment #7
jhodgdonThanks, but...
I do not think this is accurate, according to the issue summary?
Comment #8
snehi CreditAttribution: snehi as a volunteer and at Publicis Sapient for Publicis Sapient commentedDone please review.
Comment #10
joachim CreditAttribution: joachim as a volunteer commentedThis is just rewording what's already there. The point of this bug report is that the @return doesn't tell me what I will find in this array.
Imagine a developer reads about this function. What they want to know is this: 'If I do $info = getAllBundleInfo(), what is now in $info? What does it look like?'
"an array of bundle information" could be any number of things. The docs need to be specific.
Comment #11
gaurav.pahuja CreditAttribution: gaurav.pahuja as a volunteer and at Publicis Sapient commentedGiving it a try.
Comment #12
klausiSo this is an array of arrays? Then the type should be "array[]".
Format is wrong, this should be $bundle_info[BUNDLE_NAME]['label'] => LABEL
And the comment should say: "If the entity type does not have bundles then BUNDLE_TYPE is the entity type."
Unrelated change.
And then we also need to fix the similar docs on EntityTypeBundleInfoInterface::getAllBundleInfo().
Comment #13
joachim CreditAttribution: joachim as a volunteer commentedYup, my earlier comment about the format is wrong.
Here's an example, which is the output of \Drupal::service('entity_type.bundle.info')->getBundleInfo('node')
Comment #14
rajeshwari10 CreditAttribution: rajeshwari10 as a volunteer and at Blisstering Solutions commentedHi klausi,
I have done the changes as per your instructions but I didn't get the last sentence i.e.
Please guide.
Thanks!!
Comment #15
rajeshwari10 CreditAttribution: rajeshwari10 as a volunteer and at Blisstering Solutions commentedAdding Interdiff.
Comment #16
klausiPlease also fix the docs on EntityTypeBundleInfoInterface::getAllBundleInfo() which returns similar data.
Comment #17
rajeshwari10 CreditAttribution: rajeshwari10 as a volunteer and at Blisstering Solutions commentedHi klausi,
Added patch as per your suggestions.
Thanks!!
Comment #18
rajeshwari10 CreditAttribution: rajeshwari10 as a volunteer and at Blisstering Solutions commentedAdding Interdiff.
Comment #19
jhodgdonThanks! But I think this can be improved:
I think this can be documented better.
First of all, it's keyed (in this method) by entity type, then bundle name.
Second, the "format" and "example" lines will not format well on api.drupal.org
So what I suggest is something like this:
An array of bundle information. The outer array is keyed by the entity type. The next level is keyed by the bundle name. The inner arrays area associative arrays of the bundle information, such as the label for the bundle.
Then leave out the "format" and "bundles" lines.
See above. Do something similar here to describe the format.
Comment #20
rajeshwari10 CreditAttribution: rajeshwari10 as a volunteer and at Blisstering Solutions commentedHi jhodgdon,
I have done changes as you have said.
Please review the patch.
Thanks!!
Comment #21
jhodgdonBetter, thanks! I think it still can be improved though:
This all needs to be wrapped into one paragraph, with close to 80 characters (without going over) in each line.
This paragraph also needs wrapping, see above.
These two lines should be put with the first sentence (that talks about the outer array), and they shouldn't use a nonsense BUNDLE_TYPE that is not defined.
I suggest for the first sentence, it should say:
An array of bundle information where the outer array is keyed by the bundle name, or the entity type name if the entity does not have bundles.
This change has nothing to do with this issue. Remove from patch.
Comment #22
Vinay15Comment #23
klausiAn example says more than a thousand words, so I would suggest to put one in. We do that elsewhere, for example https://api.drupal.org/api/drupal/core!modules!views!src!Plugin!views!fi... with @code/@endcode tags.
Comment #24
jhodgdonI disagree in this case about putting in an example. Usually we do not have examples for simple nested array returns. Views is a big outlier in its API documentation...
Comment #25
Vinay15updated patch as per suggestions in #21.
Comment #26
Vinay15Comment #27
jhodgdonThanks! But this is still not quite right...
Under @return, the documentation lines should be indented by two spaces.
This line should not end in a space.
Similar problems with spaces here (indent, end-of-line spaces).
Also this no longer says what the inner arrays are.
Comment #28
Vinay15I have updated the patch.
Comment #29
jhodgdonThanks! I looked at the code, and I think this is accurate. It is also clear and well-formatted now.
Comment #31
jhodgdonThe usual Migrate unrelated test failure.
Comment #32
alexpottCommitted d13f93f and pushed to 8.1.x and 8.2.x. Thanks!