You are here

public function ScheduledTransitionsLocalTask::getTitle in Scheduled Transitions 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/Menu/LocalTask/ScheduledTransitionsLocalTask.php \Drupal\scheduled_transitions\Plugin\Menu\LocalTask\ScheduledTransitionsLocalTask::getTitle()

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/ScheduledTransitionsLocalTask.php, line 99

Class

ScheduledTransitionsLocalTask
Provides a local task showing count of scheduled transitions for an entity.

Namespace

Drupal\scheduled_transitions\Plugin\Menu\LocalTask

Code

public function getTitle(Request $request = NULL) {
  $entity = $this
    ->getEntityFromRouteMatch();
  if ($entity) {
    $transitionStorage = $this->entityTypeManager
      ->getStorage('scheduled_transition');
    $count = $transitionStorage
      ->getQuery()
      ->condition('entity__target_type', $entity
      ->getEntityTypeId())
      ->condition('entity__target_id', $entity
      ->id())
      ->condition('entity_revision_langcode', $this->languageManager
      ->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)
      ->getId())
      ->count()
      ->execute();
    return $this
      ->t('@title (@count)', [
      '@title' => parent::getTitle($request),
      '@count' => $count,
    ]);
  }
  return NULL;
}