Add a way to alter the rendered output used for analysis

Created on 19 November 2021, over 3 years ago
Updated 10 May 2023, about 2 years 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

Needs review

Version

2.0

Component

Code

Created by

🇧🇪Belgium tomasnagy

Live updates comments and jobs are added and updated live.
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 about 2 years 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 about 2 years 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 about 2 years 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 :)]

  • 🇧🇪Belgium chewi3

    Rerolled patch for 2.1.

Production build 0.71.5 2024