Skip to content

Instantly share code, notes, and snippets.

@thagler
Created September 16, 2016 02:40
Show Gist options
  • Save thagler/d7c47a2aa5d2ba3fe113afcc69995489 to your computer and use it in GitHub Desktop.
Save thagler/d7c47a2aa5d2ba3fe113afcc69995489 to your computer and use it in GitHub Desktop.

Revisions

  1. Tobby Hagler revised this gist Sep 16, 2016. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions get_node_by_path.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    <?php

    $path = \Drupal::service('path.alias_manager')->getPathByAlias('/this-is-the-alias');
    if(preg_match('/node\/(\d+)/', $path, $matches)) {
    $node = \Drupal\node\Entity\Node::load($matches[1]);
  2. Tobby Hagler created this gist Sep 16, 2016.
    4 changes: 4 additions & 0 deletions get_node_by_path.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    $path = \Drupal::service('path.alias_manager')->getPathByAlias('/this-is-the-alias');
    if(preg_match('/node\/(\d+)/', $path, $matches)) {
    $node = \Drupal\node\Entity\Node::load($matches[1]);
    }