You are here

public function Common::getNodeFromPath in Filebrowser 3.x

Same name and namespace in other branches
  1. 8.2 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 489

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;
}