Add a way to alter the rendered output used for analysis

Created on 19 November 2021, about 3 years ago
Updated 3 June 2023, over 1 year ago

Problem/Motivation

Adding the possibility to alter the rendered output for analysis allows for control of which theme, extra content (ie. blocks etc) to be added to the output.

Proposed resolution

An event that receives the entity and accepts rendered markup.

API changes

Added a RenderEvent that is thrown in the renderEntity function of the EntityAnalyser.

Feature request
Status

Postponed: needs info

Version

2.0

Component

Code

Created by

🇧🇪Belgium tomasnagy

Live updates comments and jobs are added and updated live.
  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

  • Needs documentation

    A documentation change is requested elsewhere. For Drupal core (and possibly other projects), once the change has been committed, this status should be recorded in a change record node.

Sign in to follow issues

Comments & Activities

Not all content is available!

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

  • 🇧🇪Belgium BramDriesen Belgium 🇧🇪

    Setting correct status. Will test this in a bit!

  • Status changed to RTBC over 1 year ago
  • 🇧🇪Belgium BramDriesen Belgium 🇧🇪

    The event subscriber works as intended. Tagging for a documentation update and/or release note.

    Small nit, we might want to leave this todo in the code as it's still valid.

    +++ b/src/EntityAnalyser.php
    @@ -137,11 +150,20 @@ class EntityAnalyser {
    -    // @todo Make the view mode configurable in Yoast SEO settings.
    
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    3 pass
  • 🇧🇪Belgium BramDriesen Belgium 🇧🇪

    Adding a patch combining this issue and 🐛 Analyze frontend theme output + issue with missing elements when analyzing Fixed . This patch should not be used to implement this issue.

  • Status changed to Postponed: needs info over 1 year ago
  • 🇳🇱Netherlands kingdutch

    Thanks for the proposed fix! I'm hesitant to implement it in the current format. We're using the event system here to replace the implementation of the renderEntity method. Since if any of the event listeners produces HTML, we don't run the default implementation of the function anymore.

    For the use-case I can come up with I would expect a single implementation of the event listener. In that case why would using Drupal's service system to replace the yoast_seo.entity_analyser not be sufficient? The method is purposefully self contained so that it can be easily overwritten by a child class (which can optionally fallback to the parent method).

    Could you describe situations in which the above service-based solution doesn't work and adding the event system provides benefits?

    [Hiding Bram's patch since it's there for convenience and not to implement the issue :)]

Production build 0.71.5 2024