You are here

class xautoload_InjectedAPI_hookXautoload in X Autoload 7.5

Same name and namespace in other branches
  1. 7.2 lib/InjectedAPI/hookXautoload.php \xautoload_InjectedAPI_hookXautoload
  2. 7.3 lib/InjectedAPI/hookXautoload.php \xautoload_InjectedAPI_hookXautoload
  3. 7.4 legacy/lib/InjectedAPI/hookXautoload.php \xautoload_InjectedAPI_hookXautoload

An instance of this class is passed around to implementations of hook_xautoload(). It acts as a wrapper around the ClassFinder, to register stuff.

Most of the methods here are deprecated. You should use the methods inherited from the base class, LocalDirectoryAdapter, instead.

Hierarchy

Expanded class hierarchy of xautoload_InjectedAPI_hookXautoload

File

legacy/lib/InjectedAPI/hookXautoload.php, line 16

View source
class xautoload_InjectedAPI_hookXautoload extends LocalDirectoryAdapter {

  /**
   * @var ExtendedClassFinderInterface
   */
  protected $finder;

  /**
   * @param ExtendedClassFinderInterface $finder
   *   The class finder object.
   * @param string $localDirectory
   *
   * @return self
   */
  static function create($finder, $localDirectory) {
    $adapter = ClassFinderAdapter::create($finder);
    return new self($adapter, $localDirectory);
  }

  /**
   * @param ClassFinderAdapter $adapter
   *   The class finder object.
   * @param string $localDirectory
   */
  function __construct($adapter, $localDirectory) {
    parent::__construct($adapter, $localDirectory);
    $this->finder = $adapter
      ->getFinder();
  }

  //                                                                Prefix stuff
  // ---------------------------------------------------------------------------

  /**
   * Register an additional prefix for this module.
   * Note: Drupal\<module name>\ is already registered for <module dir>/lib.
   *
   * @deprecated
   *
   * @param string $prefix
   *   The prefix.
   * @param string $prefix_root_dir
   *   Prefix root dir.
   *   If $relative is TRUE, this is relative to the extension module dir.
   *   If $relative is FALSE, this is an absolute path.
   * @param boolean $relative
   *   Whether or not the path is relative to the current extension dir.
   */
  function prefixRoot($prefix, $prefix_root_dir = NULL, $relative = TRUE) {
    $prefix_root_dir = $this
      ->processDir($prefix_root_dir, $relative);
    $this->finder
      ->registerPrefixRoot($prefix, $prefix_root_dir);
  }

  /**
   * Register an additional namespace for this module.
   * Note: Drupal\<module name>\ is already registered for <module dir>/lib.
   *
   * @deprecated
   *
   * @param string $prefix
   *   The namespace
   * @param string $prefix_deep_dir
   *   PSR-0 root dir.
   *   If $relative is TRUE, this is relative to the current extension dir.
   *   If $relative is FALSE, this is an absolute path.
   * @param boolean $relative
   *   Whether or not the path is relative to the current extension dir.
   */
  function prefixDeep($prefix, $prefix_deep_dir = NULL, $relative = TRUE) {
    $prefix_deep_dir = $this
      ->processDir($prefix_deep_dir, $relative);
    $this->finder
      ->registerPrefixDeep($prefix, $prefix_deep_dir);
  }

  /**
   * Legacy: Plugins were called "Handler" before.
   *
   * @deprecated
   *
   * @param string $prefix
   * @param xautoload_FinderPlugin_Interface $plugin
   *
   * @return string
   *   The key under which the plugin was registered. This can later be used to
   *   unregister the plugin again.
   */
  function prefixHandler($prefix, $plugin) {
    $key = Util::randomString();
    $this->finder
      ->registerPrefixDeep($prefix, $key, $plugin);
    return $key;
  }

  /**
   * Register a prefix plugin object
   *
   * @deprecated
   *
   * @param string $prefix
   * @param xautoload_FinderPlugin_Interface $plugin
   *
   * @return string
   *   The key under which the plugin was registered. This can later be used to
   *   unregister the plugin again.
   */
  function prefixPlugin($prefix, $plugin) {
    $key = Util::randomString();
    $this->finder
      ->registerPrefixDeep($prefix, $key, $plugin);
    return $key;
  }

  //                                                             Namespace stuff
  // ---------------------------------------------------------------------------

  /**
   * Register an additional namespace for this module.
   * Note: Drupal\<module name>\ is already registered for <module dir>/lib.
   *
   * @deprecated
   *
   * @param string $namespace
   *   The namespace
   * @param string $psr_0_root_dir
   *   PSR-0 root dir.
   *   If $relative is TRUE, this is relative to the current module dir.
   *   If $relative is FALSE, this is an absolute path.
   * @param boolean $relative
   *   Whether or not the path is relative to the current extension dir.
   */
  function namespaceRoot($namespace, $psr_0_root_dir = NULL, $relative = TRUE) {
    $psr_0_root_dir = $this
      ->processDir($psr_0_root_dir, $relative);
    $this->finder
      ->registerNamespaceRoot($namespace, $psr_0_root_dir);
  }

  /**
   * Register an additional namespace for this module.
   * Note: Drupal\<module name>\ is already registered for <module dir>/lib.
   *
   * @deprecated
   *
   * @param string $namespace
   *   The namespace
   * @param string $namespace_deep_dir
   *   PSR-0 root dir.
   *   If $relative is TRUE, this is relative to the current extension dir.
   *   If $relative is FALSE, this is an absolute path.
   * @param boolean $relative
   *   Whether or not the path is relative to the current extension dir.
   */
  function namespaceDeep($namespace, $namespace_deep_dir = NULL, $relative = TRUE) {
    $namespace_deep_dir = $this
      ->processDir($namespace_deep_dir, $relative);
    $this->finder
      ->registerNamespaceDeep($namespace, $namespace_deep_dir);
  }

  /**
   * Register a namespace plugin object
   *
   * @deprecated
   *
   * @param string $namespace
   * @param xautoload_FinderPlugin_Interface $plugin
   *
   * @return string
   *   The key under which the plugin was registered. This can later be used to
   *   unregister the plugin again.
   */
  function namespacePlugin($namespace, $plugin) {
    $key = Util::randomString();
    $this->finder
      ->registerNamespaceDeep($namespace, $key, $plugin);
    return $key;
  }

  /**
   * Legacy: Plugins were called "Handler" before.
   *
   * @deprecated
   *
   * @param string $namespace
   * @param xautoload_FinderPlugin_Interface $plugin
   *
   * @return string
   *   The key under which the plugin was registered. This can later be used to
   *   unregister the plugin again.
   */
  function namespaceHandler($namespace, $plugin) {
    $key = Util::randomString();
    $this->finder
      ->registerNamespaceDeep($namespace, $key, $plugin);
    return $key;
  }

  /**
   * Process a given directory to make it relative to Drupal root,
   * instead of relative to the current extension dir.
   *
   * @deprecated
   *
   * @param string $dir
   *   The directory path that we want to make absolute.
   * @param boolean $relative
   *   If TRUE, the $dir will be transformed from relative to absolute.
   *   If FALSE, the $dir is assumed to already be absolute, and remain unchanged.
   *
   * @return string
   *   The modified (absolute) directory path.
   */
  protected function processDir($dir, $relative) {
    if (!isset($dir)) {
      return $this->localDirectory . 'lib/';
    }
    $dir = strlen($dir) ? rtrim($dir, '/') . '/' : '';
    return $relative ? $this->localDirectory . $dir : $dir;
  }

  /**
   * Explicitly set the base for relative paths.
   *
   * Alias for LocalDirectoryAdapter::setLocalDirectory()
   *
   * @param string $dir
   *   New relative base path.
   */
  function setExtensionDir($dir) {
    $this->localDirectory = strlen($dir) ? rtrim($dir, '/') . '/' : '';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LocalDirectoryAdapter::$localDirectory protected property
LocalDirectoryAdapter::$master protected property
LocalDirectoryAdapter::absolute function Returns an adapter object that is not relative to a local directory.
LocalDirectoryAdapter::add function Adds a PSR-0 style prefix. Alias for ->addPsr0(). Overrides CommonRegistrationInterface::add
LocalDirectoryAdapter::addClassMap function Registers an array ("map") of classes to file paths. Overrides CommonRegistrationInterface::addClassMap
LocalDirectoryAdapter::addClassmapSources function Adds source paths for classmap discovery. Overrides ClassFinderAdapterInterface::addClassmapSources
LocalDirectoryAdapter::addMultiplePsr0 function Adds multiple PSR-0 prefixes. Overrides ClassFinderAdapterInterface::addMultiplePsr0
LocalDirectoryAdapter::addMultiplePsr4 function Adds multiple PSR-4 namespaces. Overrides ClassFinderAdapterInterface::addMultiplePsr4
LocalDirectoryAdapter::addNamespacePsr0 function Adds a PSR-0 style namespace. Overrides CommonRegistrationInterface::addNamespacePsr0
LocalDirectoryAdapter::addPear function Adds a PEAR-like prefix. Overrides CommonRegistrationInterface::addPear
LocalDirectoryAdapter::addPearFlat function Adds a prefix similar to PEAR, but with flat directories. Overrides CommonRegistrationInterface::addPearFlat
LocalDirectoryAdapter::addPsr0 function Adds a PSR-0 style prefix. Alias for ->add(). Overrides CommonRegistrationInterface::addPsr0
LocalDirectoryAdapter::addPsr4 function Adds a PSR-4 style namespace. Overrides CommonRegistrationInterface::addPsr4
LocalDirectoryAdapter::composerDir function Scans a directory containing Composer-generated autoload files. Overrides ClassFinderAdapterInterface::composerDir
LocalDirectoryAdapter::composerJson function Scans a composer.json file provided by a Composer package. Overrides ClassFinderAdapterInterface::composerJson
LocalDirectoryAdapter::prependMultiple protected function Prepends $this->localDirectory to a number of paths.
LocalDirectoryAdapter::prependToPaths protected function Prepends $this->localDirectory to a number of paths.
xautoload_InjectedAPI_hookXautoload::$finder protected property
xautoload_InjectedAPI_hookXautoload::create static function
xautoload_InjectedAPI_hookXautoload::namespaceDeep function Register an additional namespace for this module. Note: Drupal\<module name>\ is already registered for <module dir>/lib.
xautoload_InjectedAPI_hookXautoload::namespaceHandler function Legacy: Plugins were called "Handler" before.
xautoload_InjectedAPI_hookXautoload::namespacePlugin function Register a namespace plugin object
xautoload_InjectedAPI_hookXautoload::namespaceRoot function Register an additional namespace for this module. Note: Drupal\<module name>\ is already registered for <module dir>/lib.
xautoload_InjectedAPI_hookXautoload::prefixDeep function Register an additional namespace for this module. Note: Drupal\<module name>\ is already registered for <module dir>/lib.
xautoload_InjectedAPI_hookXautoload::prefixHandler function Legacy: Plugins were called "Handler" before.
xautoload_InjectedAPI_hookXautoload::prefixPlugin function Register a prefix plugin object
xautoload_InjectedAPI_hookXautoload::prefixRoot function Register an additional prefix for this module. Note: Drupal\<module name>\ is already registered for <module dir>/lib.
xautoload_InjectedAPI_hookXautoload::processDir protected function Process a given directory to make it relative to Drupal root, instead of relative to the current extension dir.
xautoload_InjectedAPI_hookXautoload::setExtensionDir function Explicitly set the base for relative paths.
xautoload_InjectedAPI_hookXautoload::__construct function Overrides LocalDirectoryAdapter::__construct