Scans all directories in the packages directories for available packages.
For each package a Package object is created and stored in $this->packages.

@return array
@throws Exception
@throws InvalidConfigurationException
512233
protected function scanAvailablePackages()
    {
        $newPackageStatesConfiguration = ['packages' => []];
        foreach ($this->findComposerPackagesInPath($this->packagesBasePath) as $packagePath) {
            $composerManifest = ComposerUtility::getComposerManifest($packagePath);
            if (!isset($composerManifest['name'])) {
                throw new InvalidConfigurationException(sprintf('A package composer.json was found at "%s" that contained no "name".', $packagePath), 1445933572);
            }

            if (strpos($packagePath, Files::concatenatePaths([$this->packagesBasePath, 'Inactive'])) === 0) {
                // Skip packages in legacy "Inactive" folder.
                continue;
            }

            $packageKey = $this->getPackageKeyFromManifest($composerManifest, $packagePath);
            $this->composerNameToPackageKeyMap[strtolower($composerManifest['name'])] = $packageKey;

            $packageConfiguration = $this->preparePackageStateConfiguration($packageKey, $packagePath, $composerManifest);
            if (isset($newPackageStatesConfiguration['packages'][$composerManifest['name']])) {
                throw new PackageException(
                    sprintf('The package with the name "%s" was found more than once, please make sure it exists only once. Paths "%s" and "%s".',
                        $composerManifest['name'],
                        $packageConfiguration['packagePath'],
                        $newPackageStatesConfiguration['packages'][$composerManifest['name']]['packagePath']),
                    1493030262
                );
            }

            $newPackageStatesConfiguration['packages'][$composerManifest['name']] = $packageConfiguration;
        }

        return $newPackageStatesConfiguration;
    }
353470
public function loadPackages()
    {
        $path = base_path('src');
        
        $packages = collect();

        foreach (glob($path."/*") as $directory) {
            $name = basename($directory);

            $file = $directory."/Package.php";
            $class = "{$name}\Package";

            if (File::exists($file)) {
                require_once $file;
                $class = new $class($this, $directory, $name);
                $class->boot();

                $packages[] = $class;
            }
        }


        $packages->map(function ($package) {
            $package->register();
        });
    }
1010417
public function toArray(): array
    {
        return [
            'name'         => $this->package->getName(),
            'vendorName'   => $this->getVendorName(),
            'packageName'  => $this->getPackageName(),
            'version'      => $this->package->getVersion(),
            'required'     => $this->isRequired(),
            'installed'    => $this->isInstalled(),
            'activated'    => $this->isActivated(),
            'path'         => $this->getPath(),
            'namespace'    => $this->getRootNamespace(),
            'friendlyName' => $this->getFriendlyName(),
            'type'         => $this->getFriendlyType(),
            'status'       => $this->getStatus(),
        ];
    }
533515
public function findGeneralConfiguration(): array
    {
        /** @var array[] $configurationSets */
        $configurationSets = [[]];

        $modules = $this->packageRepository->findModules();
        foreach ($modules as $module) {
            $extra = $module->getExtra();
            $this->validateGeneralConfigurationSectionInExtra($extra);
            if (!isset($extra['phplist/core']['configuration'])) {
                continue;
            }

            $configurationSets[] = $extra['phplist/core']['configuration'];
        }

        return /** @scrutinizer ignore-call */ array_replace_recursive(...$configurationSets);
    }
1139250
private function loadPackages()
    {
        foreach ($this->packages as $package) {
            /** @var $package \Phavour\Package */
            $this->packagesMetadata[$package->getPackageName()] = array(
                'namespace' => $package->getNamespace(),
                'route_path' => $package->getRoutePath(),
                'config_path' => $package->getConfigPath(),
                'package_path' => $package->getPackagePath(),
                'package_name' => $package->getPackageName()
            );
        }
    }
1118457
protected function collect_packs() {
		$iterator = new DirectoryIterator( $this->dir );

		foreach ( $iterator as $pack_dir ) {
			if ( $pack_dir->isDot() || ! $pack_dir->isDir() || ! $pack_dir->isReadable() ) {
				continue;
			}

			$pack_dirname = $pack_dir->getFilename();
			$pack_data    = $this->get_pack_data( $pack_dir );

			if ( ! empty( $pack_data ) ) {
				$this->packs[ $pack_dirname ] = $pack_data;
			}
		}
	}
44677
private function readBundleConfiguration(): array
    {
        $configurationFilePath = $this->getApplicationDir() . '/config/bundles.yml';
        if (!is_readable($configurationFilePath)) {
            throw new \RuntimeException('The file "' . $configurationFilePath . '" could not be read.', 1504272377);
        }

        return Yaml::parse(file_get_contents($configurationFilePath));
    }
1243917
public function loadTemplates()
    {
        if (!($this->configurationManager instanceof ConfigurationManager)) {
            throw new Exception('You need to install ConfigurationBundle');
        }

        $templates = new ArrayCollection([]);
        $bundles = $this->kernel->getBundles();

        /**
         * @var Bundle $bundle
         */
        foreach ($bundles as $bundle) {
            if ($bundle instanceof TemplateInterface) {
                $bundleName = $bundle->getName();
                $bundleNamespace = $bundle->getNamespace();
                $templates->set($bundleName, [
                    'bundle'    => $bundleName,
                    'namespace' => $bundleNamespace,
                    'name'      => $bundle->getTemplateName(),
                ]);
            }
        }

        $templatesArray = $templates->toArray();

        $this
            ->configurationManager
            ->set('store.templates', $templatesArray);

        return $templatesArray;
    }
148224
public function findAll() : array
    {
        $objectsData = $this->objectDataRepository->findAll();

        $objects = [];
        foreach ($objectsData as $objectData) {
            $object = $this->getOrCreateObject($objectData);

            if ($object === null) {
                throw new InvalidArgumentException('Could not create object.');
            }

            $objects[] = $object;
        }

        return $objects;
    }
23603
public static function settings(): array
    {
        $filename = static::filename();
        if (!static::checkFileExist($filename)) {
            throw new \Exception($filename . ' dosnt exists. Please create this file.');
        }
        $settings = YamlManipulator::getFileContents($filename);
        if (!isset($settings['settings'])) {
            throw new \Exception('The settigns files is not valid, all parameters must be under settings array.');
        }
        return (array)$settings['settings'];
    }
97289
public function toArray(): array
    {
        $type = $this->getType();

        if (empty($type)) {
            throw new InvalidException('Type has to be set');
        }

        return [$type->getName() => $this->_mapping];
    }
965926
public function findPackages()
    {
        $root = new Package($this->composer->getPackage(), $this->composer);
        $this->plainList[$root->getPrettyName()] = $root;
        foreach ($this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages() as $package) {
            $this->plainList[$package->getPrettyName()] = new Package($package, $this->composer);
        }
        $this->orderedList = [];
        $this->iteratePackage($root, true);

        $res = [];
        foreach (array_keys($this->orderedList) as $name) {
            $res[] = $this->plainList[$name];
        }

        return $res;
    }
679886
public function getArray()
    {
        $contents = [];

        foreach (new DirectoryIterator($this->context) as $file) {
            if ($file->isDot()) {
                continue;
            }

            $className = $file->isDir() ? 'Directory' : ucfirst(strtolower($file->getExtension()));
            $classPath = 'PHLAK\\Config\\Loaders\\' . $className;

            $loader = new $classPath($file->getPathname());

            try {
                $contents = array_merge($contents, $loader->getArray());
            } catch (InvalidFileException $e) {
                // Ignore it and continue
            }
        }

        return $contents;
    }
782140
public function getConfigFilesSorted()
    {
        $fileSystem = new Filesystem();

        $projectConfig = $fileSystem->glob(app_path('hc-config.json'));
        $packageConfigs = $fileSystem->glob(__DIR__ . '/../../../../*/*/*/hc-config.json');

        $packageConfigs = $this->sortByPriority($packageConfigs);

        $files = array_merge($packageConfigs, $projectConfig);

        return $files;
    }
188101
public function getArray()
    {
        $parsed = @parse_ini_file($this->context, true);

        if (! $parsed) {
            throw new InvalidFileException('Unable to parse invalid INI file at ' . $this->context);
        }

        return $parsed;
    }
260823
public function getAllDirectories(): array
    {
        $directories = [];

        foreach ($this->filesystem->listContents('/'.$this->path) as $info) {
            $id = $info['filename'];

            if ($this->hasDirectory($id)) {
                $directories[$id] = $this->getDirectory($id);
            }
        }

        return $directories;
    }
800064
protected function getModules()
    {
    	$file = json_decode( file_get_contents( $this->packagist . 'packages.json' ) )->includes;
    	$file = json_decode( file_get_contents( $this->packagist . key( $file ) ) );
    	return $this->normaliseData( $file->packages );
    }