- Issue created by @larowlan
- First commit to issue fork.
- Merge request !6818Resolve #3420984 "Convert layout displayvariant" β (Closed) created by godotislate
- Status changed to Needs review
9 months ago 12:08am 29 February 2024 This is similar to π Convert form and render element plugin discovery to attributes Active in that PageDisplayVariant extends DisplayVariant here (FormElement extending RenderElement in the other issue), and the same instance of VariantManager gets all the definitions for both types of plugins together.
The tricky part is this in Drupal\Core\Plugin\Discovery\AttributeDiscoveryWithAnnotations::parseClass():
// Annotations use static reflection and are able to analyze a class that // extends classes or uses traits that do not exist. Attribute discovery // will trigger a fatal error with such classes, so only call it if the // class has a class attribute. if ($reflection_class->hasClassAttribute($this->pluginDefinitionAttributeName)) { return parent::parseClass($class, $fileinfo); }
hasClassAttribute
returns TRUE if the Class .php file contains an attribute that matches$this->pluginDefinitionAttributeName
, case-insensitive. This means that classes with thePageDisplayVariant
attribute fail this check, and the class is not picked up as a plugin.The approach in the MR is to add a
hasImplementingClassAttribute()
method to use here instead ofhasClassAttribute
, and instead of a case-insensitive exact string match,is_a()
is used to check that the attribute class is the same class or subclass of$this->pluginDefinitionAttributeName
.I'm not sure whether this is the ideal approach, so I have not added tests for
hasImplementingClassAttribute()
, or even if it is OK, whetherhasImplementingClassAttribute()
should replacehasClassAttribute
altogether since the latter method is not used anywhere else. Pushing to Needs Review though to get feedback.- First commit to issue fork.
- Status changed to Needs work
9 months ago 11:52am 4 March 2024 - π«π·France andypost
Needs work to research why outdated comment was added, and not sure about tests
- Status changed to Needs review
9 months ago 4:23pm 4 March 2024 Removed @todo comment that seems to no longer apply. Added test for
hasImplementingClassAttritbute()
.- Status changed to Needs work
8 months ago 12:17am 11 March 2024 - πΊπΈUnited States smustgrave
Since this appears to be doing more then converting to attributes can the issue summary be updated to include what's being done/why it's needed in this ticket.
- Status changed to Needs review
8 months ago 1:24am 11 March 2024 Discussed with @berdir on Slack that
hasClassAttribute()
can be re-implemented withis_a
, so updated MR.- Status changed to Postponed
8 months ago 3:45pm 12 March 2024 Per suggestion from @alexpott on Slack, handling the StaticReflectionClass changes by themselves π Update Drupal\Component\Annotation\Doctrine\StaticReflectionParser::hasClassAttribute() to allow attribute subclasses Active . Blocking this on that issue.
- Status changed to Needs review
8 months ago 3:21pm 13 March 2024 π Update Drupal\Component\Annotation\Doctrine\StaticReflectionParser::hasClassAttribute() to allow attribute subclasses Active was merged, so this is unblocked now. Rebased and also updated some docblocks referencing the annotation.
- πΊπΈUnited States smustgrave
Issue summary appears to be updated.
But was still tagged for tests so leaving in review for those.
Tests were done in π Update Drupal\Component\Annotation\Doctrine\StaticReflectionParser::hasClassAttribute() to allow attribute subclasses Active , so removing tag.
- πΊπΈUnited States smustgrave
Could a follow up be opened for
Maybe there should be a follow-up issue about investigating usage of DisplayVariant vs PageDisplayVariant, and whether there even needs to be the two classes?
Then probably good to mark this one.
Created follow up: π Consolidate layout DisplayVariant, PageDisplayVariant plugin types Active
- Status changed to RTBC
8 months ago 6:39pm 18 March 2024 - Status changed to Needs work
8 months ago 8:38am 20 March 2024 - π¬π§United Kingdom alexpott πͺπΊπ
Post a review to the MR - I think we should require an admin label because these things have to be listed in the UI.
- Status changed to Needs review
8 months ago 2:31pm 20 March 2024 - Status changed to RTBC
8 months ago 6:20pm 20 March 2024 - πΊπΈUnited States smustgrave
Appears feedback from @alexpott has been addressed
- π¬π§United Kingdom alexpott πͺπΊπ
Committed and pushed 99fc430601 to 11.x and f267065695 to 10.3.x. Thanks!
-
alexpott β
committed f2670656 on 10.3.x
Issue #3420984 by godotislate, andypost, smustgrave, larowlan, alexpott...
-
alexpott β
committed f2670656 on 10.3.x
- Status changed to Fixed
8 months ago 8:27am 21 March 2024 -
alexpott β
committed 99fc4306 on 11.x
Issue #3420984 by godotislate, andypost, smustgrave, larowlan, alexpott...
-
alexpott β
committed 99fc4306 on 11.x
Automatically closed - issue fixed for 2 weeks with no activity.