Convert Layout plugin discovery to attributes

Created on 13 February 2024, 5 months ago
Updated 3 May 2024, about 2 months ago

Problem/Motivation

In ๐Ÿ“Œ Use PHP attributes instead of doctrine annotations Fixed we added support for attribute based plugin discovery.
As part of that issue we converted block and action plugins.

This issue is to convert \Drupal\Core\Layout\Annotation\Layout plugins to use Attributes.

Proposed resolution

  1. Add a class to represent the new Attribute - Example
  2. Update the plugin manager constructor to include both the attribute and annotation class names - example
  3. Convert all plugins that use the annotation to use the new attribute - example

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ“Œ Task
Status

Fixed

Version

10.3 โœจ

Component
Baseย  โ†’

Last updated about 2 hours ago

Created by

๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @larowlan
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK

    ๐Ÿ› Add missing category to Drupal\layout_builder\Plugin\Layout\BlankLayout and let modules and themes alter the list of layouts RTBC notes that the label and category properties are actually required, so we could make that change in the conversion to attributes.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Ruturaj Chaubey Pune, India

    Ruturaj Chaubey โ†’ made their first commit to this issueโ€™s fork.

  • Pipeline finished with Failed
    4 months ago
    Total: 188s
    #100572
  • Status changed to Needs work 4 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia mstrelan

    Setting NW since there is an MR, but it's failing tests

  • First commit to issue fork.
  • Pipeline finished with Canceled
    4 months ago
    Total: 41s
    #107923
  • Pipeline finished with Failed
    4 months ago
    Total: 184s
    #107924
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone New Zealand

    There are comments in \Drupal\Core\Layout\Annotation\Layout that have not been copied over. I reckon they should be.

  • Pipeline finished with Failed
    4 months ago
    Total: 217s
    #111322
  • Pipeline finished with Failed
    4 months ago
    Total: 189s
    #111358
  • Pipeline finished with Failed
    4 months ago
    Total: 175s
    #111989
  • Pipeline finished with Failed
    3 months ago
    Total: 189s
    #122988
  • Pipeline finished with Failed
    3 months ago
    Total: 185s
    #129459
  • Pipeline finished with Failed
    3 months ago
    Total: 495s
    #129468
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone New Zealand

    I've been attempting to fix the phpstan errors.

    The addition of context_definitions was made because it is used in the plugin definition in \Drupal\layout_builder_test\Plugin\Layout\TestContextAwareLayout.

  • Pipeline finished with Failed
    3 months ago
    Total: 614s
    #131438
  • Pipeline finished with Failed
    3 months ago
    Total: 578s
    #131511
  • Pipeline finished with Failed
    3 months ago
    Total: 560s
    #132216
  • Pipeline finished with Failed
    3 months ago
    Total: 176s
    #132219
  • Pipeline finished with Failed
    3 months ago
    Total: 576s
    #132221
  • Pipeline finished with Failed
    3 months ago
    Total: 146s
    #132228
  • Pipeline finished with Failed
    3 months ago
    Total: 491s
    #132230
  • Pipeline finished with Failed
    3 months ago
    Total: 492s
    #132236
  • Pipeline finished with Failed
    2 months ago
    Total: 995s
    #147971
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia kim.pepper ๐Ÿ„โ€โ™‚๏ธ๐Ÿ‡ฆ๐Ÿ‡บSydney, Australia

    kim.pepper โ†’ made their first commit to this issueโ€™s fork.

  • Pipeline finished with Failed
    2 months ago
    Total: 1018s
    #153857
  • Pipeline finished with Failed
    2 months ago
    Total: 1077s
    #153865
  • Added a few comments to the MR. The plugin manager getDiscovery() needs to be updated to use attribute discovery classes, similar to the changes needed for ๐Ÿ“Œ CKEditor5PluginManager: use PHP attributes instead of doctrine annotations Needs work .

    Also, once that change is done, other changes might be needed for to pass tests. For example, at least one of the yaml-defined test layout plugins in web/core/tests/Drupal/Tests/Core/Layout/LayoutPluginManagerTest.php looks like this:

    module_a_derived_layout:
      deriver: \Drupal\Tests\Core\Layout\LayoutDeriver
      array_based: true
    

    In which case, arguments in attribute constructor would need to be changed to optional, since the deriver will be providing those properties instead.

  • Pipeline finished with Failed
    2 months ago
    Total: 615s
    #156702
  • Pipeline finished with Failed
    2 months ago
    Total: 185s
    #156905
  • Pipeline finished with Failed
    2 months ago
    Total: 506s
    #156913
  • Pipeline finished with Failed
    2 months ago
    Total: 638s
    #156920
  • Pipeline finished with Success
    2 months ago
    Total: 567s
    #156976
  • Status changed to Needs review 2 months ago
  • Made the switch to Attribute discovery and got tests to all green.

    Re #2 ๐Ÿ“Œ Convert Layout plugin discovery to attributes Active :
    The 'label' property is now required, but somewhere along the way category was set to optional. This might worth more consideration, depending on whether the label and category could be set by the deriver, with validation to completed in ๐Ÿ› Add missing category to Drupal\layout_builder\Plugin\Layout\BlankLayout and let modules and themes alter the list of layouts RTBC .

  • Pipeline finished with Failed
    2 months ago
    Total: 199s
    #157014
  • Status changed to Needs work 2 months ago
  • The Needs Review Queue Bot โ†’ tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • Pipeline finished with Success
    2 months ago
    Total: 598s
    #157058
  • Status changed to Needs review 2 months ago
  • Pipeline finished with Success
    2 months ago
    Total: 501s
    #157591
  • Status changed to RTBC 2 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    I believe all feedback has been addressed on the MR. All 9 instances of @Layout have been replaced.

    Believe this is good.

  • First commit to issue fork.
  • Pipeline finished with Canceled
    about 2 months ago
    #159527
  • Pipeline finished with Canceled
    about 2 months ago
    #159539
  • Status changed to Needs review about 2 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    I made some improvements to the attribute param docs. I've just got one outstanding question on the MR about the use of ...$additional

  • Pipeline finished with Canceled
    about 2 months ago
    #159541
  • Pipeline finished with Failed
    about 2 months ago
    #159550
  • Status changed to Needs work about 2 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    Okay... do we have test coverage of step 3?

    Also tests are failing due to a new layout in core. We need to consider the new Navigation module - that adds a layout without a label. I think we should consider a BC layer where we add a label for unlabelled layouts and trigger a deprecation.

  • Okay... do we have test coverage of step 3?

    The change here is that previously step 3 was converting all the plugin data back to Layout annotations via AnnotationBridgeDecorator, while now they're converted to Layout attributes via AttributeBridgeDecorator instead. I was assuming that existing test coverage for Layout discovery (mostly in LayoutPluginManagerTest) + Drupal\Tests\Component\Plugin\Discovery\AttributeBridgeDecoratorTest was enough, unless there's something I'm missing.

    Also tests are failing due to a new layout in core. We need to consider the new Navigation module - that adds a layout without a label. I think we should consider a BC layer where we add a label for unlabelled layouts and trigger a deprecation.

    Should we address that in this issue, or allow label and category to be optional for now and push requiring them back to ๐Ÿ› Add missing category to Drupal\layout_builder\Plugin\Layout\BlankLayout and let modules and themes alter the list of layouts RTBC ?

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    Should we address that in this issue, or allow label and category to be optional for now and push requiring them back to

    That seems extremely reasonable... yeah let's make them optional for now. Maybe the category is not optional? But yeah let's do this work rather than more.

  • Pipeline finished with Success
    about 2 months ago
    Total: 626s
    #159819
  • Pipeline finished with Failed
    about 2 months ago
    Total: 245s
    #159902
  • Pipeline finished with Success
    about 2 months ago
    #159910
  • Status changed to Needs review about 2 months ago
  • Made label and category optional. Added tests that arbitrary properties are being set correctly via YML and PHP attributes.

  • Status changed to RTBC about 2 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    I think this looks ready now, thanks everyone, applied one minor nit from my review

  • Pipeline finished with Success
    about 2 months ago
    Total: 501s
    #163015
  • Pipeline finished with Success
    about 2 months ago
    Total: 624s
    #163046
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone New Zealand

    Many days ago I made a suggestion to the summary line in a test Layout plugin but did not submit it. I have just done so and then accepted my own suggestion. I did that because it was minor and in a test file.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    Committed and pushed 091483c1f1 to 11.x and 36c7397511 to 10.4.x and fce131c9ae to 10.3.x. Thanks!

    • alexpott โ†’ committed fce131c9 on 10.3.x
      Issue #3420983 by sorlov, godotislate, alexpott, quietone, kim.pepper,...
  • Status changed to Fixed about 2 months ago
    • alexpott โ†’ committed 36c73975 on 10.4.x
      Issue #3420983 by sorlov, godotislate, alexpott, quietone, kim.pepper,...
Production build 0.69.0 2024