public function Common::getNodeFromPath in Filebrowser 8.2
Same name and namespace in other branches
- 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\ServicesCode
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;
}