You are here

protected function MenuBlock::getActiveTrailParentTitle in Menu Block 8

Gets the title of the parent of the active menu item.

Return value

string|null The title of the parent of the active menu item, the title of the active item if it has no parent, or NULL if there's no active menu item.

1 call to MenuBlock::getActiveTrailParentTitle()
MenuBlock::getBlockLabel in src/Plugin/Block/MenuBlock.php
Gets the configured block label.

File

src/Plugin/Block/MenuBlock.php, line 472

Class

MenuBlock
Provides an extended Menu block.

Namespace

Drupal\menu_block\Plugin\Block

Code

protected function getActiveTrailParentTitle() {

  /** @var array $active_trail_ids */
  $active_trail_ids = $this
    ->getDerivativeActiveTrailIds();
  if ($active_trail_ids) {
    if (count($active_trail_ids) === 1) {
      return $this
        ->getActiveItemTitle();
    }
    return $this
      ->getLinkTitleFromLink(next($active_trail_ids));
  }
}