You are here

class xautoload_Plugin_DrupalExtensionLibPSR0 in X Autoload 7.2

Hierarchy

Expanded class hierarchy of xautoload_Plugin_DrupalExtensionLibPSR0

File

lib/Plugin/DrupalExtensionLibPSR0.php, line 4

View source
class xautoload_Plugin_DrupalExtensionLibPSR0 extends xautoload_Plugin_WithKillswitch {
  protected $system;

  /**
   * @param xautoload_DrupalExtensionSystem $system
   *   Abstraction of Drupal's extension system.
   */
  function __construct($system) {
    $this->system = $system;
  }

  /**
   * The way this plugin is registered, it will only ever be called if the
   * class is within the \Drupal\ namespace. All the DIRECTORY_SEPARATOR in the
   * $path parameter were namespace separators before.
   *
   * @param xautoload_InjectedAPI_findFile $api
   *   API object with suggestFile() method.
   * @param string $Drupal_string
   *   The way we register this plugin, this parameter will always be a string
   *   with value "Drupal/".
   * @param string $path
   *   The part of the PSR-0 path after "Drupal/". E.g., if the class is
   *   "Drupal\ab_cd\SomeClass", then this will be "ab_cd/SomeClass.php".
   *
   * @return boolean
   *   TRUE, if we found it.
   */
  function findFile($api, $Drupal_string, $path) {
    $pos = strpos($path, DIRECTORY_SEPARATOR);
    if (FALSE !== $pos) {
      $extension = substr($path, 0, $pos);
      $extension_path = $this->system
        ->getExtensionPath($extension);
      if (!empty($extension_path)) {
        $path = $extension_path . '/lib/Drupal/' . $path;
        if ($api
          ->suggestFile($path)) {
          return TRUE;
        }
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
xautoload_Plugin_DrupalExtensionLibPSR0::$system protected property
xautoload_Plugin_DrupalExtensionLibPSR0::findFile function The way this plugin is registered, it will only ever be called if the class is within the \Drupal\ namespace. All the DIRECTORY_SEPARATOR in the $path parameter were namespace separators before. Overrides xautoload_Plugin_Interface::findFile
xautoload_Plugin_DrupalExtensionLibPSR0::__construct function
xautoload_Plugin_WithKillswitch::$id protected property
xautoload_Plugin_WithKillswitch::$key protected property
xautoload_Plugin_WithKillswitch::$map protected property
xautoload_Plugin_WithKillswitch::setKillswitch function Allow the namespace plugin to unsubscribe or replace itself. This is called by the ClassFinder itself, the moment the namespace plugin is registered.