You are here

public function QuickNodeCloneNodeFinder::findNodeFromCurrentPath in Quick Node Clone 8

Derive node data from the current path.

Return value

\Drupal\Core\Entity\EntityInterface|null Either returns an entity, or null if none found.

File

src/QuickNodeCloneNodeFinder.php, line 68

Class

QuickNodeCloneNodeFinder
Helper class.

Namespace

Drupal\quick_node_clone

Code

public function findNodeFromCurrentPath() {
  $path = $this->requestStack
    ->getCurrentRequest()
    ->getRequestUri();
  $path_data = explode('/', $path);
  if ($this
    ->currentPathIsValidClonePath()) {

    // By this point, we should be on a quick node clone path.
    $node_path = '/node/' . $path_data[2];
    return $this
      ->findNodeFromPath($node_path);
  }
  return NULL;
}