You are here

function DrupalGetFilename::drupalGetFilename in X Autoload 7.5

Replicates drupal_get_filename(*, *, NULL)

Parameters

string $type:

string $name:

Return value

string|null

1 call to DrupalGetFilename::drupalGetFilename()
DrupalGetFilename::drupalGetPath in tests/src/VirtualDrupal/DrupalGetFilename.php

File

tests/src/VirtualDrupal/DrupalGetFilename.php, line 54

Class

DrupalGetFilename

Namespace

Drupal\xautoload\Tests\VirtualDrupal

Code

function drupalGetFilename($type, $name) {

  // Profiles are a special case: they have a fixed location and naming.
  if ($type == 'profile') {
    $profile_filename = "profiles/{$name}/{$name}.profile";
    $this->files[$type][$name] = file_exists($profile_filename) ? $profile_filename : FALSE;
  }

  // Look in runtime cache.
  if (isset($this->files[$type][$name])) {
    return $this->files[$type][$name];
  }

  // Load from the database.
  $file = $this->systemTable
    ->moduleGetFilename($name);
  if (isset($file) && file_exists($file)) {
    $this->files[$type][$name] = $file;
    return $file;
  }

  // Fallback: Search the filesystem.
  $this->files[$type] = $this->exampleModules
    ->discoverModuleFilenames($type);
  if (isset($this->files[$type][$name])) {
    return $this->files[$type][$name];
  }
  return NULL;
}