public function MenuLinkAttribute::resolve in GraphQL 8.4
Resolver.
Parameters
\Drupal\Core\Menu\MenuLinkInterface $link:
string $attribute:
Return value
mixed
File
- src/
Plugin/ GraphQL/ DataProducer/ Menu/ MenuLink/ MenuLinkAttribute.php, line 41
Class
- MenuLinkAttribute
- Returns the attribute(s) of a menu link.
Namespace
Drupal\graphql\Plugin\GraphQL\DataProducer\Menu\MenuLinkCode
public function resolve(MenuLinkInterface $link, $attribute) {
$options = $link
->getOptions();
// Certain attributes like class can be arrays. Check for that and implode
// them.
$attributeValue = NestedArray::getValue($options, [
'attributes',
$attribute,
]);
if (is_array($attributeValue)) {
return implode(" ", $attributeValue);
}
else {
return $attributeValue;
}
}