Error when adding the referenced entity to the path pattern

Created on 21 June 2024, 10 months ago

Problem/Motivation

When I save content that has an automatic URL pattern of type `simplenews_issue` associated with it, I get the following error:

"Error: Object of class Drupal\simplenews\Entity\Newsletter could not be converted to string in Drupal\Component\Render\HtmlEscapeText->__construct() (line 31 of core/lib/Drupal/Component/Render/HtmlEscapeText.php).".

Steps to reproduce

  1. Create a URL pattern with the Pathauto module that includes the `[node:simplenews_issue:entity]` token for the `simplenews_issue` content type.
  2. Add a `simplenews_issue` content type with the necessary data.
  3. Save the newly added content.

Proposed resolution

I have added the magic method `__toString()` to the Newsletter entity to solve the problem.

Remaining tasks

The following solution is an interim solution to the problem at hand, but the correct solution would be for the entity to provide all fields of the referenced entity (such as taxonomy terms) along with their tokens.

💬 Support request
Status

Needs work

Version

4.0

Component

Code

Created by

🇪🇸Spain einarulfhednar

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024