Skip to content
Snippets Groups Projects
Commit 2f280556 authored by Samuel Oltz's avatar Samuel Oltz
Browse files

only allow TitleResolver to check for alternative field on fieldable entities. Fixes #3253835

parent d929a158
No related branches found
No related tags found
1 merge request!32Issue #3253835: TitleResolver checks for alternative field on non-fieldable entities
...@@ -7,6 +7,7 @@ use Drupal\Core\Url; ...@@ -7,6 +7,7 @@ use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route; use Symfony\Component\Routing\Route;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Component\Utility\Xss; use Drupal\Component\Utility\Xss;
...@@ -61,7 +62,7 @@ class TitleResolver extends ControllerTitleResolver { ...@@ -61,7 +62,7 @@ class TitleResolver extends ControllerTitleResolver {
} }
if ($entity !== NULL) { if ($entity !== NULL) {
$alternative_title_field = $this->config->get(EasyBreadcrumbConstants::ALTERNATIVE_TITLE_FIELD); $alternative_title_field = $this->config->get(EasyBreadcrumbConstants::ALTERNATIVE_TITLE_FIELD);
if ($entity->hasField($alternative_title_field) && !$entity->get($alternative_title_field) if ($entity instanceof FieldableEntityInterface && $entity->hasField($alternative_title_field) && !$entity->get($alternative_title_field)
->isEmpty()) { ->isEmpty()) {
return Xss::filter($entity->get($alternative_title_field)->value); return Xss::filter($entity->get($alternative_title_field)->value);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment