public function SocialSimpleGenerator::getTitle in Social simple 2.0.x
Same name and namespace in other branches
- 8 src/SocialSimpleGenerator.php \Drupal\social_simple\SocialSimpleGenerator::getTitle()
Get the title to share.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity if provided.
Return value
string $title The entity title or page title to share.
Overrides SocialSimpleGeneratorInterface::getTitle
1 call to SocialSimpleGenerator::getTitle()
- SocialSimpleGenerator::generateSocialLinks in src/
SocialSimpleGenerator.php - Build the social share links.
File
- src/
SocialSimpleGenerator.php, line 148
Class
- SocialSimpleGenerator
- Class SocialSimpleGenerator.
Namespace
Drupal\social_simpleCode
public function getTitle(EntityInterface $entity = NULL) {
$title = NULL;
if ($entity) {
$title = $entity
->label();
}
elseif ($route_object = $this->currentRouteMatch
->getRouteObject()) {
$title = $this->titleResolver
->getTitle($this->requestStack
->getCurrentRequest(), $route_object);
}
if (is_string($title)) {
return $title;
}
elseif (is_array($title)) {
return $this->renderer
->render($title);
}
elseif ($title instanceof MarkupInterface) {
return (string) $title;
}
return '';
}