You are here

public static function Nodes::pathExists in Hook Update Deploy Tools 7

Check if path exists in drupal.

Parameters

string $path: The path of the node to import/update.

string $language: The langage of the alias to look up (node->language).

Return value

bool TRUE if the path exists. FALSE if the path does not exist.

1 call to Nodes::pathExists()
Nodes::processOne in src/Nodes.php
Validated Updates/Imports one page from the contents of an import file.

File

src/Nodes.php, line 413

Class

Nodes
Public method for changing nodes programatically.

Namespace

HookUpdateDeployTools

Code

public static function pathExists($path, $language) {
  $exists = FALSE;
  $source_path = drupal_lookup_path('source', $path, $language);
  if (!empty($source_path)) {

    // Valid path found simply.
    $exists = TRUE;
  }
  else {

    // Must look deeper.
    $useable_path = !empty($source_path) ? $source_path : $path;
    $valid = drupal_valid_path($useable_path);
    if ($valid) {
      $exists = TRUE;
    }
  }
  return $exists;
}