/**
  * Looks for packages in the specified directories and creates the objects
  */
 public function findAll($paths = [])
 {
     if (!empty($this->packages)) {
         return $this->packages;
     }
     $this->packages = [];
     if (empty($paths)) {
         $paths = $this->paths;
     }
     foreach ($paths as $path) {
         /** @var \creocoder\flysystem\LocalFilesystem $fileSystem */
         $fileSystem = new LocalFilesystem(["path" => $path]);
         foreach ($fileSystem->listContents() as $item) {
             if ($item["type"] == "dir") {
                 $path = $fileSystem->getAdapter()->applyPathPrefix($item["path"]);
                 if (!file_exists($path . DIRECTORY_SEPARATOR . 'composer.json') || ($package = $this->findByPath($path)) == null) {
                     continue;
                 }
                 if ($package instanceof PackageInfo) {
                     $this->packages[$package->getPackage()] = $package;
                 } else {
                     $this->packages[$package['configuration']->name()] = $package;
                 }
             }
         }
     }
     return $this->packages;
 }
 public static function getHassCoreFile()
 {
     $filesystem = \Yii::createObject(["class" => LocalFilesystem::className(), "path" => __DIR__]);
     $classMaps = [];
     foreach ($filesystem->listContents() as $item) {
         if ($item["type"] == "dir") {
             $path = $filesystem->getAdapter()->applyPathPrefix($item["path"]);
             if (!file_exists($path . DIRECTORY_SEPARATOR . 'composer.json')) {
                 continue;
             }
             $reader = new ConfigurationReader();
             $configuration = $reader->read($path . DIRECTORY_SEPARATOR . 'composer.json');
             foreach (array_keys($configuration->autoloadPsr4()) as $namespace) {
                 $classMaps[$namespace] = $path;
             }
         }
     }
     return $classMaps;
 }
 public function writeFile($classMaps)
 {
     /** @var LocalFilesystem $filesystem **/
     $filesystem = \Yii::createObject(["class" => LocalFilesystem::className(), "path" => "@core"]);
     if ($filesystem->has("autoload_psr4.php")) {
         $filesystem->delete("autoload_psr4.php");
     }
     $classMapsString = "<?php\n\n return " . var_export($classMaps, true) . ";";
     $filesystem->write("autoload_psr4.php", $classMapsString);
 }