/**
  * @param string[] $classes
  *
  * @return array
  */
 protected static function buildSnapshot($classes)
 {
     $observations = array();
     // Test that all classes are available immediately at boot time.
     foreach ($classes as $class) {
         $observations['class_exists'][$class] = class_exists($class);
     }
     // Check variable_get().
     // @FIXME
     // // @FIXME
     // // The correct configuration object could not be determined. You'll need to
     // // rewrite this call manually.
     // $observations[XAUTOLOAD_VARNAME_CACHE_TYPES] = variable_get(XAUTOLOAD_VARNAME_CACHE_TYPES);
     // @FIXME
     // // @FIXME
     // // The correct configuration object could not be determined. You'll need to
     // // rewrite this call manually.
     // $observations[XAUTOLOAD_VARNAME_CACHE_LAZY] = variable_get(XAUTOLOAD_VARNAME_CACHE_LAZY);
     $observations['db_connection_info'] = \Database::getConnectionInfo();
     $spl_autoload_stack = array();
     foreach (spl_autoload_functions() as $callback) {
         $spl_autoload_stack[] = Util::callbackToString($callback);
     }
     $observations['spl_autoload_functions'] = $spl_autoload_stack;
     return $observations;
 }
 /**
  * Renew the cache prefix, save it, and notify all observers.
  */
 function renewCachePrefix()
 {
     $this->prefix = Util::randomString();
     $this->system->variableSet(XAUTOLOAD_VARNAME_CACHE_PREFIX, $this->prefix);
     foreach ($this->observers as $observer) {
         $observer->setCachePrefix($this->prefix);
     }
 }
 /**
  * Renew the cache prefix, save it, and notify all observers.
  */
 function renewCachePrefix()
 {
     $this->prefix = Util::randomString();
     variable_set('xautoload_cache_prefix', $this->prefix);
     foreach ($this->observers as $observer) {
         $observer->setCachePrefix($this->prefix);
     }
 }
 function testAutoloadStackOrder()
 {
     $expected = array('Drupal\\xautoload\\ClassFinder\\ClassFinder->loadClass()', 'drupal_autoload_class', 'drupal_autoload_interface', '_simpletest_autoload_psr0');
     $actual = array();
     foreach (spl_autoload_functions() as $callback) {
         $actual[] = Util::callbackToString($callback);
     }
     $this->assertEqualBlock($expected, $actual, "SPL autoload stack:");
 }
 /**
  * {@inheritdoc}
  */
 function guessPath($file)
 {
     if (file_exists($file)) {
         require_once $file;
         return Util::classIsDefined($this->className);
     } else {
         return FALSE;
     }
 }
 /**
  * @param string[] $classes
  *
  * @return array
  */
 protected static function buildSnapshot($classes)
 {
     $observations = array();
     // Test that all classes are available immediately at boot time.
     foreach ($classes as $class) {
         $observations['class_exists'][$class] = class_exists($class);
     }
     // Check variable_get().
     $observations[XAUTOLOAD_VARNAME_CACHE_TYPES] = variable_get(XAUTOLOAD_VARNAME_CACHE_TYPES);
     $observations[XAUTOLOAD_VARNAME_CACHE_LAZY] = variable_get(XAUTOLOAD_VARNAME_CACHE_LAZY);
     $observations['db_connection_info'] = \Database::getConnectionInfo();
     $spl_autoload_stack = array();
     foreach (spl_autoload_functions() as $callback) {
         $spl_autoload_stack[] = Util::callbackToString($callback);
     }
     $observations['spl_autoload_functions'] = $spl_autoload_stack;
     return $observations;
 }
 /**
  * {@inheritdoc}
  */
 function guessPath($file)
 {
     if (file_exists($file)) {
         // The file must be included, or else we can't know if it defines the class.
         require_once $file;
         if (Util::classIsDefined($this->className)) {
             $this->file = $file;
             return TRUE;
         }
     }
     return FALSE;
 }
 /**
  * {@inheritdoc}
  */
 function addPear($prefix, $paths)
 {
     $logical_base_path = Util::prefixLogicalPath($prefix);
     foreach ((array) $paths as $root_path) {
         $deep_path = strlen($root_path) ? rtrim($root_path, '/') . '/' . $logical_base_path : $logical_base_path;
         $this->prefixMap->registerDeepPath($logical_base_path, $deep_path, $this->defaultBehavior);
     }
 }
 /**
  * {@inheritdoc}
  */
 function guessPath($file)
 {
     if (file_exists($file)) {
         require_once $file;
         if (Util::classIsDefined($this->className)) {
             $this->file = $file;
             return TRUE;
         }
     }
     return FALSE;
 }
 /**
  * @param ClassFinderAdapter $adapter
  * @param array $prefixes
  */
 protected function addMultipleWithTargetDir($adapter, array $prefixes)
 {
     $default_behavior = new DefaultDirectoryBehavior();
     $psr0_behavior = new Psr0DirectoryBehavior();
     $namespace_map = array();
     $prefix_map = array();
     $target_dir_strlen = strlen($this->targetDir);
     foreach ($prefixes as $prefix => $paths) {
         if (FALSE === strpos($prefix, '\\')) {
             $logical_base_path = Util::prefixLogicalPath($prefix);
             foreach ((array) $paths as $root_path) {
                 $deep_path = strlen($root_path) ? rtrim($root_path, '/') . '/' . $logical_base_path : $logical_base_path;
                 if (0 !== strpos($deep_path, $this->targetDir)) {
                     continue;
                 }
                 $deep_path = $this->pathPrefix . substr($deep_path, $target_dir_strlen);
                 $prefix_map[$logical_base_path][$deep_path] = $default_behavior;
             }
         }
         $logical_base_path = Util::namespaceLogicalPath($prefix);
         foreach ((array) $paths as $root_path) {
             $deep_path = strlen($root_path) ? rtrim($root_path, '/') . '/' . $logical_base_path : $logical_base_path;
             if (0 !== strpos($deep_path, $this->targetDir)) {
                 continue;
             }
             $deep_path = $this->pathPrefix . substr($deep_path, $target_dir_strlen);
             $namespace_map[$logical_base_path][$deep_path] = $psr0_behavior;
         }
     }
     if (!empty($prefix_map)) {
         $adapter->getPrefixMap()->registerDeepPaths($prefix_map);
     }
     $adapter->getNamespaceMap()->registerDeepPaths($namespace_map);
 }
 function __construct()
 {
     $this->instanceKey = Util::randomString();
     self::$instances[$this->instanceKey] = $this;
 }
Exemple #12
0
 /**
  * {@inheritdoc}
  */
 function registerNamespaceDeepLocation($namespace, $path, $behavior = NULL)
 {
     if (!isset($behavior)) {
         $behavior = $this->defaultBehavior;
     }
     $namespace_path_fragment = Util::namespaceLogicalPath($namespace);
     $deep_path = strlen($path) ? $path . '/' : '';
     $this->namespaceMap->registerDeepPath($namespace_path_fragment, $deep_path, $behavior);
 }
 /**
  * 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;
 }