Issue Event for Row Rendering

Created on 26 October 2023, 7 months ago
Updated 28 November 2023, 6 months ago

Problem/Motivation

The current way the usage table is rendered is not easily modifiable, and if multiple patches are needed (to provide customizations of how each row is output), it can quickly become unwieldy.

Steps to reproduce

N/A

Proposed resolution

Introduce a new event, `EntityUsageRowRenderEvent`, that gets dispatched to determine the values used for each row. This would allow other modules to override things like the labels or link to the entity without the need to patch the module.

Remaining tasks

This might be a way to implement part of the refactoring task β†’

User interface changes

N/A

API changes

Introduces a new event

Data model changes

N/A

✨ Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States partyka

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Issue created by @partyka
  • πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA
  • Status changed to Needs review 7 months ago
  • πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA

    I think this approach makes sense. I'm not sure if it's worth having the module itself provide the "starter" event subsubscriber to provide all the initial data for the row or not. I don't think it's a super common pattern to do that, rather the module would still have its core business logic present to get those starter values, then dispatch an event with those values to allow other modules to alter them. Though, this method does make it easier for some other module to completely disable the main event subscriber if they want.

    Are the module maintainers on board with an approach like this? If so, maybe we can get some tests written.

  • πŸ‡ΊπŸ‡ΈUnited States partyka

    I don't think it's a super common pattern to do that, rather the module would still have its core business logic present to get those starter values, then dispatch an event with those values to allow other modules to alter them. Though, this method does make it easier for some other module to completely disable the main event subscriber if they want.

    I agree that it's not super common, but the reason I chose to do this here was flexibility -- like you said to disable the main subscriber if desired. You could also disable the main event subscriber and override the "starter" subscriber if your use case allows for it.

  • Status changed to Needs work 7 months ago
  • πŸ‡ͺπŸ‡ΈSpain marcoscano Barcelona, Spain

    Thank you for creating this and for the MR.
    I think it's OK to open an integration point and allow modules to alter the row contents. However, as mentioned above, I would rather have the current code do its thing and just dispatch the event (or even a good ol' alter hook, it works fine for me), so other modules can alter the contents of the generated row. I could see the most common use for this would be to tweak things a bit, not re-writing everything entirely. (maybe if projects need to do something completely different it would be easier to just take over the controller at that point?)

    In my mind with this new hook/event there would be a small performance penalty to all sites, for the benefit of the ones that do need to alter something, but I believe the trade-off is worth it.

    Thanks,

  • πŸ‡ΊπŸ‡ΈUnited States partyka

    I could see the most common use for this would be to tweak things a bit, not re-writing everything entirely. (maybe if projects need to do something completely different it would be easier to just take over the controller at that point?)

    Agreed .. I just thought that it made the most sense to provide the module's default event implementation using the same mechanism provided to anyone else who might be interested. Of course, the original way works too and I can see merit to that as often there's just a tweak needed by a consuming module. FWIW, doing it this way helped me identify an appropriate place to fire the event.

    Just please let me know if, after considering this, you'd still like to have the generated row implementation in the controller.

  • πŸ‡ͺπŸ‡ΈSpain marcoscano Barcelona, Spain

    Just please let me know if, after considering this, you'd still like to have the generated row implementation in the controller.

    Yes, I think this would be the preferred approach, for maintainability reasons at this point. Thanks! πŸ‘

  • Status changed to Needs review 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States partyka
  • Status changed to Needs work 6 months ago
  • πŸ‡ͺπŸ‡ΈSpain marcoscano Barcelona, Spain

    @partyka thanks for working on this. The MR is still marked as Draft, can you please remove that when it's ready for review?
    (also, there seems to be a lot of changes in the controller code that may not be related to this change? It would be great if we could remove those to make reviewing easier)
    Thanks!

  • Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update 6 months ago
    Waiting for branch to pass
  • Status changed to Needs review 6 months ago
Production build 0.69.0 2024