/**
  * This method has side effects, so it is not the constructor.
  *
  * @param \Drupal\xautoload\DrupalSystem\DrupalSystemInterface $system
  *
  * @return CacheManager
  */
 static function create(DrupalSystemInterface $system)
 {
     $prefix = $system->variableGet(XAUTOLOAD_VARNAME_CACHE_PREFIX, NULL);
     $manager = new self($prefix, $system);
     if (empty($prefix)) {
         $manager->renewCachePrefix();
     }
     return $manager;
 }
 /**
  * Runs hook_xautoload() on all enabled modules.
  *
  * This may occur multiple times in a request, if new modules are enabled.
  *
  * @param array $modules
  */
 private function runHookXautoload(array $modules)
 {
     // Let other modules register stuff to the finder via hook_xautoload().
     $adapter = \xautoload_InjectedAPI_hookXautoload::create($this->finder, '');
     foreach ($modules as $module) {
         $adapter->setExtensionDir($dir = $this->system->drupalGetPath('module', $module));
         $function = $module . '_xautoload';
         $function($adapter, $dir);
     }
 }
 /**
  * @return array[]
  */
 private function buildLibrariesXautoloadInfo()
 {
     // @todo Reset drupal_static('libraries') ?
     $all = array();
     foreach ($this->system->getLibrariesInfo() as $name => $info) {
         serialize($info);
         if (!isset($info['xautoload'])) {
             continue;
         }
         $callback = $info['xautoload'];
         if (!is_callable($callback)) {
             continue;
         }
         /** See https://www.drupal.org/node/2473901 */
         $path = isset($info['library path']) ? $info['library path'] : $this->system->librariesGetPath($name);
         if (FALSE === $path) {
             continue;
         }
         $all[$name] = array($path, $callback);
     }
     return $all;
 }