- Issue created by @eduardo morales alberti
- Merge request !80Issue #3500242 by eduardo morales alberti: Name property from BreadcrumbList... → (Open) created by eduardo morales alberti
When we tried to export content using default content we get the following error:
Object support when dumping a YAML file has been disabled
Debugging we saw that the error comes from the metatag breadcrumb and comparing it with the other metatags the name property is a \Drupal\Core\StringTranslation\TranslatableMarkup object instead of a string.
The problem comes from \Drupal\schema_metatag\Plugin\schema_metatag\PropertyType\BreadcrumbList::getItems
public function getItems($input_value) {
$values = [];
if (!empty($input_value)) {
$entity_route = $this->routeMatch->getCurrentRouteMatch();
$breadcrumbs = $this->breadcrumbManager->build($entity_route)->getLinks();
$key = 1;
foreach ($breadcrumbs as $item) {
....
$text = $item->getText();
...
$values[$key] = [
'@id' => $url,
'name' => $text,
'item' => $url,
];
$key++;
}
}
return $values;
}
The method \Drupal\Core\Link::getText returns and \Drupal\Core\StringTranslation\TranslatableMarkup and default content expects a string.
Install metatag and schema_metatag
Configure the schema breadcrumb metatag on a content.
Create a node and export it using default content.
Cast the TranslatableMarkup to a string.
Active
3.0
Code