class MenuLinkContentLinkTarget
Provides a MenuLinkContent link target handler.
MenuLinkContent entities are atypical because they describe a link to elsewhere and don't have a canonical route to view them. So when linking to such an entity, the link target must be their destination.
Hierarchy
- class \Drupal\menu_link_content\Entity\MenuLinkContentLinkTarget implements \Drupal\Core\Entity\EntityLinkTargetInterface
Expanded class hierarchy of MenuLinkContentLinkTarget
See also
\Drupal\menu_link_content\MenuLinkContentInterface::getUrlObject()
File
-
core/
modules/ menu_link_content/ src/ Entity/ MenuLinkContentLinkTarget.php, line 21
Namespace
Drupal\menu_link_content\EntityView source
class MenuLinkContentLinkTarget implements EntityLinkTargetInterface {
/**
* {@inheritdoc}
*/
public function getLinkTarget(EntityInterface $entity) : GeneratedUrl {
assert($entity instanceof MenuLinkContentInterface);
return $entity->getUrlObject()
->toString(TRUE);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.