As stated in the documentation the $base_plugin_definition parameter is an array but this is not always true. For instance, definition for layout plugins is stored in an object (LayoutDefinition).
I would change the array to mixed or array|object since it can be both array and object.
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | drupal_wrong_documentation-2900883-21.patch | 870 bytes | kalyansamanta |
Comments
Comment #2
larskhansen commentedI'll have a patch for this.
Comment #3
larskhansen commentedComment #4
larskhansen commentedComment #5
gaëlgMinor change: just fixed the issue tags
Comment #6
gaëlgThanks for the patch. The doc text still mentioned an array. I copy-pasted some part of the getDerivativeDefinition() method which explained that it can be an array or an object.
Comment #8
chi commentedWould this be better to use array|object instead of mixed?
Comment #9
larskhansen commentedIf it only receives either an array or a object - then yes. It would be better with array|object.
Comment #10
larskhansen commentedComment #11
chi commentedLooks good for me.
Comment #12
gábor hojtsyDo we know which kind of object / which interface it would implement? That would be tremendously more useful than just saying "object".
Comment #13
chi commentedAs far as I know LayoutDefinition is the only non-array definition for this moment.
Comment #14
larskhansen commentedIf LayoutDefinition is the only object - then let us write that.
If there are more than two objects - then let us keep the array|object.
Comment #15
chi commentedLayoutDefinition is the only object definition in Drupal core. Since it it technically possible contributed and custom modules may also implement definitions as objects.
Comment #16
tim.plunkettarray|\Drupal\Component\Plugin\Definition\PluginDefinitionInterfacewould be the correct approach.Object-based plugin definitions MUST implement this interface.
Comment #17
tim.plunkettAnd LayoutDefinition is the second object-based definition.
The first was ConfigEntityType/ContentEntityType (\Drupal\Core\Entity\EntityTypeInterface)
Comment #19
larskhansen commentedHi,
I'm at Drupal Developer Days in Lissabon 2018 and are giving this another go.
I've created a patch as Tim Plunkett describes.
But shouldn't getDerivativeDefinition only accept a "PluginDefinitionInterface" and not an array of "PluginDefinitionInterface"?
I think getDerivativeDefinitions should be used for an array of "PluginDefinitionInterface". Or am I way off here?
But for now - the patch follows Tims suggestion.
BR Lars Hansen
Comment #21
kalyansamanta commentedComment #22
joachim commentedLGTM.
Comment #23
alexpottCommitted and pushed 6429dc64ba to 8.7.x and c66a0b71a7 to 8.6.x. Thanks!
Backported to 8.6.x as a docs fix.