/** * Load the extension autoload.json cache file and build the PackageDescriptor array. * * @return PackageDescriptor[] */ private function loadPackageDescriptors() { $descriptors = []; try { /** @var JsonFile $autoload */ $autoload = $this->extFs->get('vendor/autoload.json'); } catch (FileNotFoundException $e) { return $descriptors; } // Get extensions we're managing via the autoloader foreach ((array) $autoload->parse() as $name => $loader) { $descriptors[$name] = PackageDescriptor::create($loader); } return $descriptors; }
/** * Appends an existing set of files/directories to the finder. * * The set can be another Finder, an Iterator, an IteratorAggregate, or even a plain array. * * @param mixed $iterator * * @throws InvalidArgumentException When the given argument is not iterable. * * @return Finder The finder */ public function append($iterator) { if ($iterator instanceof \IteratorAggregate) { $this->iterators[] = $iterator->getIterator(); } elseif ($iterator instanceof \Iterator) { $this->iterators[] = $iterator; } elseif ($iterator instanceof \Traversable || is_array($iterator)) { $it = new \ArrayIterator(); foreach ($iterator as $file) { $it->append($file instanceof Flysystem\Handler ? $file : $this->filesystem->get($file)); } $this->iterators[] = $it; } else { throw new InvalidArgumentException('Finder::append() method wrong argument type.'); } return $this; }
/** * Constructor. * * @param FilesystemInterface $filesystem The filesystem to search * @param string $glob The glob pattern * @param int $flags A bitwise combination of the flag constants in {@see Glob} */ public function __construct(FilesystemInterface $filesystem, $glob, $flags = 0) { // Glob code requires absolute paths, so prefix path // with leading slash, but not before mount point if (strpos($glob, '://') > 0) { $glob = str_replace('://', ':///', $glob); } else { $glob = '/' . ltrim($glob, '/'); } if (!Glob::isDynamic($glob)) { // If the glob is a file path, return that path. $innerIterator = new \ArrayIterator([$glob => $filesystem->get($glob)]); } else { $basePath = Glob::getBasePath($glob); $innerIterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($filesystem, $basePath, RecursiveDirectoryIterator::KEY_FOR_GLOB), RecursiveIteratorIterator::SELF_FIRST); } parent::__construct($glob, $innerIterator, static::FILTER_KEY, $flags); }