public function PublishContentLocalTask::getTitle in Publish Content 8
Returns the localized title to be shown for this tab.
Subclasses may add optional arguments like NodeInterface $node = NULL that will be supplied by the ControllerResolver.
Return value
string The title of the local task.
Overrides LocalTaskDefault::getTitle
File
- src/
Plugin/ Menu/ LocalTask/ PublishContentLocalTask.php, line 60
Class
- PublishContentLocalTask
- Defines a local task plugin with a dynamic title.
Namespace
Drupal\publishcontent\Plugin\Menu\LocalTaskCode
public function getTitle(Request $request = NULL) {
$langcode = $this->languageManager
->getCurrentLanguage()
->getId();
/** @var \Drupal\node\NodeInterface $node */
$node = $this->nodeStorage
->load($this->routeMatch
->getRawParameter('node'));
if ($node
->isTranslatable() && $node
->hasTranslation($langcode)) {
$translatedNode = $node
->getTranslation($langcode);
return $translatedNode
->isPublished() ? $this->config
->get('unpublish_text_value') : $this->config
->get('publish_text_value');
}
return $node
->isPublished() ? $this->config
->get('unpublish_text_value') : $this->config
->get('publish_text_value');
}