Skip to content
Snippets Groups Projects
Commit 3179bbd9 authored by Mikael Meulle's avatar Mikael Meulle Committed by Pierre Dureau
Browse files

Issue #3479850 by just_like_good_vibes, g4mbini: LinksPropType: improve pagers...

Issue #3479850 by just_like_good_vibes, g4mbini: LinksPropType: improve pagers compatibility by casting title to string
parent e654bf14
No related branches found
No related tags found
1 merge request!239Resolve #3479850 "2.0.0 beta4 linksproptype normalization"
Pipeline #306313 passed with warnings
......@@ -99,35 +99,45 @@ class LinksPropType extends PropTypePluginBase implements ContainerFactoryPlugin
unset($value[$index]);
continue;
}
$item = self::normalizeAttributes($item);
if (array_key_exists("text", $item)) {
// Examples: links.html.twig, breadcrumb.html.twig, pager.html.twig,
// views_mini_pager.html.twig.
if (is_scalar($item["text"]) || $item["text"] instanceof \Stringable) {
$item["title"] = (string) $item["text"];
}
else {
$item["title"] = $item["text"];
}
unset($item["text"]);
}
if (!array_key_exists("title", $item)) {
if (!isset($item["title"])) {
$item["title"] = (string) $index;
}
if (array_key_exists("href", $item)) {
// Examples: pager.html.twig, views_mini_pager.html.twig.
$item["url"] = $item["href"];
unset($item["href"]);
$value[$index] = self::normalizeLink($item);
}
return array_values($value);
}
/**
* Normalize link.
*/
protected static function normalizeLink(array $item): array {
$item = self::normalizeAttributes($item);
if (array_key_exists("text", $item)) {
// Examples: links.html.twig, breadcrumb.html.twig, pager.html.twig,
// views_mini_pager.html.twig.
if (is_scalar($item["text"]) || $item["text"] instanceof \Stringable) {
$item["title"] = (string) $item["text"];
}
$item = self::extractLinkData($item);
$item = self::normalizeUrl($item);
$item = static::normalizeAttributes($item, "link_attributes");
if (array_key_exists("below", $item)) {
$item["below"] = self::normalize($item["below"]);
else {
$item["title"] = $item["text"];
}
$value[$index] = $item;
unset($item["text"]);
}
return array_values($value);
if (!is_string($item["title"])) {
$item["title"] = (string) $item["title"];
}
if (array_key_exists("href", $item)) {
// Examples: pager.html.twig, views_mini_pager.html.twig.
$item["url"] = $item["href"];
unset($item["href"]);
}
$item = self::extractLinkData($item);
$item = self::normalizeUrl($item);
$item = static::normalizeAttributes($item, "link_attributes");
if (array_key_exists("below", $item)) {
$item["below"] = self::normalize($item["below"]);
}
return $item;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment