You are here

public function Common::getNodeFromPath in Filebrowser 8.2

Same name and namespace in other branches
  1. 3.x src/Services/Common.php \Drupal\filebrowser\Services\Common::getNodeFromPath()

Returns node object from path (if any), or NULL.

Parameters

RouteMatchInterface $route_match:

Return value

Node|Null

File

src/Services/Common.php, line 485

Class

Common
Class Common @package Drupal\filebrowser\Services

Namespace

Drupal\filebrowser\Services

Code

public function getNodeFromPath($route_match = NULL) {
  $route_match = $route_match ?: \Drupal::routeMatch();
  if ($node = $route_match
    ->getParameter('node')) {
    if (!is_object($node)) {

      // The parameter is node ID.
      $node = Node::load($node);
    }
    return $node;
  }
  return NULL;
}