/**
  * Find the file for a class that in PSR-0 or PEAR would be in
  * $psr_0_root . '/' . $path_fragment . $path_suffix
  *
  * @param InjectedApiInterface $api
  * @param string $logical_base_path
  * @param string $relative_path
  *
  * @return bool|null
  *   TRUE, if the file was found.
  *   FALSE or NULL, otherwise.
  */
 function findFile($api, $logical_base_path, $relative_path) {
   // Prevent recursion if this is called from libraries_info().
   foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $call) {
     if ('libraries_info' === $call['function']) {
       return FALSE;
     }
   }
   $this->finder->getNamespaceMap()->unregisterDeepPath('', '');
   $this->finder->getPrefixMap()->unregisterDeepPath('', '');
   $this->registerAllLibraries();
   return $this->finder->apiFindFile($api, $api->getClass());
 }
 /**
  * Register lazy plugins for enabled Drupal modules and themes, assuming that
  * we don't know yet whether they use PSR-0, PEAR-Flat, or none of these.
  *
  * @param string[] $extensions
  *   An array where the keys are extension names, and the values are extension
  *   types like 'module' or 'theme'.
  */
 private function _registerLazyExtensionPlugins(array $extensions)
 {
     $namespaceBehaviors = array();
     $prefixBehaviors = array();
     foreach (array('module', 'theme') as $extension_type) {
         $namespaceBehaviors[$extension_type] = new DrupalExtensionNamespaceFinderPlugin($extension_type, $this->finder->getNamespaceMap(), $this->finder->getPrefixMap(), $this->system);
         $prefixBehaviors[$extension_type] = new DrupalExtensionUnderscoreFinderPlugin($extension_type, $this->finder->getNamespaceMap(), $this->finder->getPrefixMap(), $this->system);
     }
     $prefix_map = array();
     $namespace_map = array();
     foreach ($extensions as $name => $type) {
         if (empty($namespaceBehaviors[$type])) {
             // Unsupported extension type, e.g. "theme_engine".
             // This can happen if a site was upgraded from Drupal 6.
             // See https://drupal.org/comment/8503979#comment-8503979
             continue;
         }
         if (!empty($this->registered[$name])) {
             // The extension has already been processed.
             continue;
         }
         $namespace_map['Drupal/' . $name . '/'][$name] = $namespaceBehaviors[$type];
         $prefix_map[str_replace('_', '/', $name) . '/'][$name] = $prefixBehaviors[$type];
         $this->registered[$name] = TRUE;
     }
     $this->finder->getNamespaceMap()->registerDeepPaths($namespace_map);
     $this->finder->getPrefixMap()->registerDeepPaths($prefix_map);
 }
 /**
  * @param ExtendedClassFinderInterface $finder
  *   The class finder object.
  * @param ClassMapGeneratorInterface $classmap_generator
  */
 function __construct($finder, $classmap_generator)
 {
     $this->finder = $finder;
     $this->prefixMap = $finder->getPrefixMap();
     $this->namespaceMap = $finder->getNamespaceMap();
     $this->defaultBehavior = new DefaultDirectoryBehavior();
     $this->psr0Behavior = new Psr0DirectoryBehavior();
     $this->classMapGenerator = $classmap_generator;
 }
 /**
  * @param DrupalSystemInterface $system
  * @param ExtendedClassFinderInterface $finder
  */
 function __construct(DrupalSystemInterface $system, ExtendedClassFinderInterface $finder)
 {
     $this->system = $system;
     $this->finder = $finder;
     $this->namespaceMap = $finder->getNamespaceMap();
     $this->prefixMap = $finder->getPrefixMap();
     foreach (array('module', 'theme') as $extension_type) {
         $this->namespaceBehaviors[$extension_type] = new DrupalExtensionNamespaceFinderPlugin($extension_type, $this->namespaceMap, $this->prefixMap, $this->system);
         $this->prefixBehaviors[$extension_type] = new DrupalExtensionUnderscoreFinderPlugin($extension_type, $this->namespaceMap, $this->prefixMap, $this->system);
     }
     $this->defaultBehavior = new DefaultDirectoryBehavior();
 }
 /**
  * Wake up after a cache fail.
  *
  * @param ExtendedClassFinderInterface $finder
  *   The class finder object, with any cache decorator peeled off.
  * @param string[] $extensions
  *   Currently enabled extensions. Extension type by extension name.
  */
 public function wakeUp(ExtendedClassFinderInterface $finder, array $extensions)
 {
     $plugin = new DrupalCoreRegistryPlugin(DRUPAL_ROOT . '/');
     $finder->getNamespaceMap()->registerDeepPath('', 'registry', $plugin);
     $finder->getPrefixMap()->registerDeepPath('', 'registry', $plugin);
 }
Пример #6
0
 /**
  * Registers all libraries that have an "xautoload" setting.
  */
 private function registerLibrariesFinderPlugin()
 {
     $plugin = new LibrariesFinderPlugin($this->finder, $this->system);
     $this->finder->getPrefixMap()->registerDeepPath('', '', $plugin);
     $this->finder->getNamespaceMap()->registerDeepPath('', '', $plugin);
 }