You are here

class DrupalExtensionUnderscoreFinderPlugin in X Autoload 7.4

Same name and namespace in other branches
  1. 7.5 src/ClassFinder/Plugin/DrupalExtensionUnderscoreFinderPlugin.php \Drupal\xautoload\ClassFinder\Plugin\DrupalExtensionUnderscoreFinderPlugin

Hierarchy

Expanded class hierarchy of DrupalExtensionUnderscoreFinderPlugin

1 file declares its use of DrupalExtensionUnderscoreFinderPlugin
DrupalExtensionAdapter.php in lib/Adapter/DrupalExtensionAdapter.php

File

lib/ClassFinder/Plugin/DrupalExtensionUnderscoreFinderPlugin.php, line 5

Namespace

Drupal\xautoload\ClassFinder\Plugin
View source
class DrupalExtensionUnderscoreFinderPlugin extends DrupalExtensionNamespaceFinderPlugin {

  /**
   * {@inheritdoc}
   */
  function findFile($api, $logical_base_path, $relative_path, $extension_name = NULL) {
    $extension_file = $this->system
      ->drupalGetFilename($this->type, $extension_name);
    if (empty($extension_file)) {

      // Extension does not exist, or is not installed.
      return FALSE;
    }
    $nspath = 'Drupal/' . $extension_name . '/';
    $testpath = $nspath . 'Tests/';
    $uspath = $extension_name . '/';
    $lib = dirname($extension_file) . '/lib/';
    $lib_psr0 = $lib . 'Drupal/' . $extension_name . '/';

    // Try PEAR-Flat.
    if ($api
      ->guessPath($lib . $relative_path)) {

      // Register PEAR-Flat.
      $this->prefixMap
        ->registerDeepPath($uspath, $lib, $this->defaultBehavior);

      // Unregister the lazy plugins.
      $this->namespaceMap
        ->unregisterDeepPath($nspath, $extension_name);
      $this->prefixMap
        ->unregisterDeepPath($uspath, $extension_name);

      // See if there are PSR-0 or PSR-4 test classes.
      if (is_dir($lib_psr0 . 'Tests/')) {
        $this->namespaceMap
          ->registerDeepPath($testpath, $lib_psr0 . 'Tests/', $this->psr0Behavior);
      }
      if (is_dir($lib . 'Tests/')) {
        $this->namespaceMap
          ->registerDeepPath($testpath, $lib . 'Tests/', $this->defaultBehavior);
      }

      // The class was found, so return TRUE.
      return TRUE;
    }
  }

}

Members