You are here

public function NodeHierarchyController::getTitle in Entity Reference Hierarchy 8

1 string reference to 'NodeHierarchyController::getTitle'
entity_hierarchy.routing.yml in ./entity_hierarchy.routing.yml
entity_hierarchy.routing.yml

File

src/Controller/NodeHierarchyController.php, line 18
Contains \Drupal\entity_hierarchy\Controller\NodeHierarchyController.

Class

NodeHierarchyController
Controller routines for book routes.

Namespace

Drupal\entity_hierarchy\Controller

Code

public function getTitle() {

  // Is there really no better way to do this?
  $url = \Drupal\Core\Url::fromRoute('<current>');
  $curr_path = $url
    ->toString();
  $path = explode('/', $curr_path);
  $nid = $path[2];
  $node = Node::load($nid);
  if (is_object($node)) {
    return t('Children of %t', array(
      '%t' => $node
        ->getTitle(),
    ));
  }
}