Compile a new plugin manifest.

@param array $directories

@throws Exception

@return array
488828
public function compileManifest(array $directories)
    {
        $manifest = [];

        foreach ($directories as $directory) {
            // Find the root file of each plugin.
            // As we load the plugins from the mu-plugins directory
            // we do not need to get their header. Only the file
            // that defines them.
            if ($payload = $this->getPlugin($directory)) {
                $manifest[$directory] = $payload;
            }
        }

        return $this->writeManifest($manifest);
    }
265233
protected function processPlugins($plugins, $dir)
    {
        foreach ($plugins as $plugin) {
            $this->addPlugin($plugin, $dir);
        }
    }
1056614
protected static function emulateObjectDirectories(array $object, array $directories, array $listedDirectories)
    {
        if ($object['type'] === 'dir') {
            $listedDirectories[] = $object['path'];
        }

        if (empty($object['dirname'])) {
            return [$directories, $listedDirectories];
        }

        $parent = $object['dirname'];

        while (!empty($parent) && !\in_array($parent, $directories, true)) {
            $directories[] = $parent;
            $parent = static::dirname($parent);
        }

        if (isset($object['type']) && $object['type'] === 'dir') {
            $listedDirectories[] = $object['path'];

            return [$directories, $listedDirectories];
        }

        return [$directories, $listedDirectories];
    }
356878
public function directories($directory)
    {
        return collect($this->filesystem->directories($directory))
            ->map(function ($file) {
                return new File($file, $this);
            });
    }
735149
public function mkdir($dirs, $mode = 0777)
    {
        foreach ($this->toIterable($dirs) as $dir) {
            if (is_dir($dir)) {
                continue;
            }

            if (!self::box('mkdir', $dir, $mode, true)) {
                if (!is_dir($dir)) {
                    // The directory was not created by a concurrent process. Let's throw an exception with a developer friendly error message if we have one
                    if (self::$lastError) {
                        throw new IOException(sprintf('Failed to create "%s": %s.', $dir, self::$lastError), 0, null, $dir);
                    }
                    throw new IOException(sprintf('Failed to create "%s"', $dir), 0, null, $dir);
                }
            }
        }
    }
829480
public function compileAll()
    {
        $this->emptyCompileDir();
        
        $this->compileOtherFiles();
        
        $manifestNames = $this->config()->precompile;
        
        foreach ($manifestNames as $manifest) {
            $ext = pathinfo($manifest, PATHINFO_EXTENSION);
            $paths = $this->findAllFiles($manifest);
            foreach ($paths as $path) {
                $this->compileFile(new File($ext, $path));
            }
        }
    }
542644
protected function makeDir($paths = '')
    {
        foreach ((array) $paths as $path) {
            $path = $this->extensionPath($path);

            $this->filesystem->makeDirectory($path, 0755, true, true);
        }
    }
382765
public function makeDirectory($subDir = '')
    {
        if ($this->blob === null) {
            throw new \Exception('Blob path is not set yet.');
        }

        if ($subDir) {
            $name = $this->getUniqueFileName($this->blob->path, Str::slug($subDir));
            $this->blob->path = trim($this->blob->path . '/' . $name, '/\\');
        }

        if ($this->blob->path !== '') {
            $this->storage->makeDirectory($this->blob->path);
        }

        return $this;
    }
1122926
private function getFileInfoObjectsInDirs(array $dirs): array
    {
        $finder   = new Finder();
        $iterable = $finder->files()->in($dirs);

        return iterator_to_array($iterable);
    }
297545
protected function doDiscovery(array $directories, $base_namespace)
    {
        $forms = [];
        $filter = $this->filterByNamespace($base_namespace);

        foreach ($this->searchFiles($directories, $filter) as $file) {
            $ext = $file->getExtension();
            $classname = $base_namespace . '\\' . $file->getBasename(".$ext");

            if (!class_exists($classname)) {
                throw new \Exception(
                    'Missing class found during form discovery.'
                );
            }
            $instance = new $classname();

            if (!$instance instanceof FormInterface) {
                throw new \Exception(
                    sprintf('Form class (%s) is missing \Droath\ConsoleForm\Form\FormInterface.', $classname)
                );
            }

            $forms[$instance->getName()] = $instance->buildForm();
        }

        return $forms;
    }
955646
private static function pluginFolderPaths($plugins, $folder_path)
    {
        $paths = [];

        foreach ($plugins as $path) {
            $iterator = new \DirectoryIterator($path);

            /** @var \DirectoryIterator $directory */
            foreach ($iterator as $directory) {
                if (!$directory->isDir() || $directory->isDot()) {
                    continue;
                }

                // Path to the languages folder
                $lang_path = $directory->getPathName() . '/' . $folder_path;

                // If this folder exists, add it to the list of paths
                if (file_exists($lang_path)) {
                    $paths []= $lang_path;
                }
            }
        }
        return $paths;
    }
45790
public function addDirs($dirs) {
        if(!is_array($dirs)) {
            $dirs = array($dirs);
        }

        $this->dirs = array_merge($this->dirs, $dirs);
    }
529252
public function _buildFileList($files, $dir)
    {
        $list = array();

        $dir = realpath($dir);
        if (!$dir) {
            return $list;
        }
        $dir = $this->fixPath($dir);

        foreach ($files as $filename) {
            $filename = $this->makeAbsolutePath(trim($filename), $dir);
            $globResults = glob($filename); // switch slashes since old versions of glob need forward slashes
            if ($globResults) {
                foreach ($globResults as $filepath) {
                    $okay = TRUE;
                    foreach ($this->_ignore as $ignore) {
                        if (strstr($filepath, trim($ignore))) {
                            $okay = FALSE;
                        }
                    }
                    if ($okay) {
                        $list[] = realpath($filepath);
                    }
                }
            } elseif (!$this->_subdirs) {
                $this->error('Could not find file "'.$filename.'"');
            }
        }

        if ($this->_subdirs) { // recurse into subdir
            $globResults = glob($dir.'*', GLOB_ONLYDIR); // get subdirs
            if ($globResults) {
                foreach ($globResults as $dirName) {
                    $okay = TRUE;
                    foreach ($this->_ignore as $ignore) {
                        if (strstr($dirName, trim($ignore))) {
                            $okay = FALSE;
                        }
                    }
                    if ($okay && (GLOB_ONLYDIR || is_dir($dirName))) { // handle missing only dir support
                        $list = array_merge($list, $this->_buildFileList($files, $this->makeAbsolutePath($dirName, $this->_path)));
                    }
                }
            }
        }

        return $list;
    }
362964
private function buildFileList($directories = [], $fileList = [])
    {
        $output = [];
        foreach ($directories as $directory) {
            foreach ($fileList as $file) {
                $fileName = $directory . DIRECTORY_SEPARATOR . $file;

                if (is_file($fileName) && is_readable($fileName)) {
                    $output[] = $fileName;
                }
            }
        }

        return $output;
    }
1359586
public function loadFromDirectory($dir)
    {
        if (!is_dir($dir)) {
            throw new \InvalidArgumentException(sprintf('"%s" does not exist', $dir));
        }

        $installers = [];
        $includedFiles = [];

        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($dir),
            \RecursiveIteratorIterator::LEAVES_ONLY
        );

        foreach ($iterator as $file) {
            if (($fileName = $file->getBasename($this->fileExtension)) == $file->getBasename()) {
                continue;
            }
            $sourceFile = realpath($file->getPathName());
            require_once $sourceFile;
            $includedFiles[] = $sourceFile;
        }
        $declared = get_declared_classes();

        foreach ($declared as $className) {
            $refClass = new \ReflectionClass($className);
            $sourceFile = $refClass->getFileName();

            if (in_array($sourceFile, $includedFiles) && !$this->isTransient($className)) {
                $installer = new $className;
                $installers[] = $installer;
                $this->addInstaller($installer);
            }
        }

        return $installers;
    }
858366
private function loadCategoriesFromClassContentDirectories($directories)
    {
        $classcontents = [];
        foreach ($directories as $directory) {
            $classcontents = array_merge($classcontents, self::getClassContentClassnamesFromDir($directory));
        }

        foreach ($classcontents as $class) {
            try {
                if (class_exists($class)) {
                    $this->buildCategoryFromClassContent(new $class());
                }
            } catch (ClassNotFoundException $e) {
                // nothing to do
            }
        }
    }
496176
public function addSubdirectories(array $directories)
    {
        foreach ($directories as $dir) {
            $this->subdirs[$dir] = $dir;
        }

        return $this;
    }