Add the alias packages.

@param PackageInterface $package         The current package
@param string           $aliasNormalized The alias version normalizes

@return PackageInterface
196362
protected function addPackageAliases(PackageInterface $package, $aliasNormalized)
    {
        $alias = new AliasPackage($package, $aliasNormalized, $this->rootPackageVersion);
        $this->addPackage($alias);

        if (false === strpos('dev-', $aliasNormalized)) {
            $alias = new AliasPackage($package, $aliasNormalized.'-dev', $this->rootPackageVersion);
            $this->addPackage($alias);
        }

        return $package;
    }
205634
public function addPackage($alias, $package)
    {
        $container = $this->getContainer();

        if (is_string($package)) {
            if (!class_exists($package)) {
                return null;
            }

            /** @var \Windwalker\Core\Package\AbstractPackage $package */
            $package = $this->container->newInstance($package);
        }

        if (!$package) {
            return null;
        }

        // If we set custom name to package, use this as alias.
        if (!is_numeric($alias)) {
            $package->setName($alias);
        }

        // Get package identify name.
        $name = $package->getName();

        // Set container and init it
        $subContainer = $container->createChild($name);

        $package->setContainer($subContainer)->boot();

        /** @var WindwalkerApplicationInterface $application */
        $application = $container->get('application');

        // If in Console mode, register commands.
        if ($application->isConsole()) {
            $package->registerCommands($application);
        }

        $container->share('package.' . $name, $package);
        $this->packages[$name] = $package;

        $subContainer->alias('package', 'package.' . $name);

        // Add alias map
        $this->aliases[get_class($package)] = $name;

        return $package;
    }
808160
private function createPackages(array $packages)
    {
        $matcherPackages = [];

        foreach ($packages as $package) {
            $reflection = new ReflectionClass($package);

            if ($reflection->implementsInterface(self::PACKAGE_REGISTRAR) === false) {
                throw NotAvailableException::createForPackage(self::PACKAGE_REGISTRAR);
            }
            $matcherPackages[] = $reflection->newInstance();
        }

        return $matcherPackages;
    }
1062494
public function addProvider(ProviderInterface $provider, $alias, $priority)
    {
        $this->providers[$alias] = array(
            'provider' => $provider,
            'priority' => $priority,
            'alias' => $alias,
        );

        uasort(
            $this->providers,
            function ($a, $b) {
                if ($a['priority'] == $b['priority']) {
                    return 0;
                }

                return $a['priority'] < $b['priority'] ? 1 : -1;
            }
        );
    }
739806
protected function deleteIgnoredFiles(PackageInterface $package)
    {
        $manager = IgnoreFactory::create($this->config, $this->composer, $package, $this->getInstallPath($package));

        if ($manager->isEnabled() && !$manager->hasPattern()) {
            $this->addIgnorePatterns($manager, $package);
        }

        $manager->cleanup();
    }
78067
public function package(string $package, ?string $namespace = null) : void {
        if (is_null($namespace)) {
            list($vendor, $namespace) = explode('/', $package);
        }

        $this->finder->addNamespace($namespace, $package);
    }
1295496
private function updateConfigFile(PackageInterface $package)
    {
        $defaultConfigFile = $this->projectPath . self::DS .
            'App' . self::DS . 'Resource' . self::DS . 'config' . self::DS . 'config.default.php';

        if (is_writeable($defaultConfigFile)) {
            $output = include $defaultConfigFile;
            $bundleConf = [
                'bundles' => [
                    $this->getPackageName($package) => []
                ]
            ];

            $data = array_merge($output, $bundleConf);

            if (false === file_put_contents($defaultConfigFile, '<?php return ' . var_export($data, true) . ';')) {
                throw new RuntimeException(sprintf('Cannot update config file "%s"', $defaultConfigFile));
            }
        }
    }
956606
private function findSubPackages(PackageInterface $package): Generator
    {
        $readMes = new \Symfony\Component\Finder\Finder();
        $readMes->files()
                ->in($package->getPaths())
                ->depth(1)
                ->name('readme.md');

        // If no sub-folders have a readme, there aren't any sub-packages here.
        if (!$readMes->count()) {
            return;
        }
        yield from $this->scanNamespaceForPackages($package, $package);
    }
1148276
public function package($package, $hint, $namespace = null)
    {
        $namespace = $this->getPackageNamespace($package, $namespace);

        $this->addNamespace($namespace, $hint);
    }
1022259
public function getInstallPath(PackageInterface $package)
    {
        $type = $package->getType();
        if (substr($type, 0, strlen(self::NAME)) !== self::NAME) {
            throw new InvalidArgumentException(
                'Sorry the package type of this package is not yet supported.'
            );
        }

        $subPackageType = substr($type, strlen(self::NAME) + 1);

        $prettyName = $package->getPrettyName();
        if (strpos($prettyName, '/') !== false) {
            list($vendor, $name) = explode('/', $prettyName);
        } else {
            $vendor = '';
            $name = $prettyName;
        }

        $extra = $package->getExtra();
        if (!empty($extra['installer-name'])) {
            $name = $extra['installer-name'];
        }

        $availableVars = compact('name', 'vendor', 'type');

        if ($this->composer->getPackage()) {
            $extra = $this->composer->getPackage()->getExtra();
            if (!empty($extra['installer-paths'])) {
                $customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type, $vendor);
                if (!empty($customPath)) {
                    return $this->templatePath($customPath, $availableVars);
                }
            }
        }

        $locations = self::LOCATIONS;
        if (!isset($locations[$subPackageType])) {
            throw new InvalidArgumentException(sprintf('Sub-package type "%s" is not supported', $type));
        }

        return $this->templatePath($locations[$subPackageType], $availableVars);
    }
1001152
public function getInstallPath(PackageInterface $package)
    {
        if ($this->solver->isSharedPackage($package)) {
            return $this->symlinkInstaller->getInstallPath($package);
        }

        return $this->defaultInstaller->getInstallPath($package);
    }
871513
public function getPackageTranslations(Package $package)
    {
        $localStats = $this->localFactory->getAvailablePackageStats($package);
        $remoteStats = $this->remoteProvider->getAvailablePackageStats($package->getPackageHandle(), $package->getPackageVersion());

        return $this->computeUpdates($localStats, $remoteStats, $package);
    }
1218339
public function updateEntry($package)
	{
		$this->verifyCommand($package);

		$lines = file($this->less);

		// Set the new colors
		$lines[0] = '@bg:                ' . $package['bg'] . ";\n";
		$lines[1] = '@gray:              ' . $package['gray'] . ";\n";
		$lines[2] = '@brand-primary:     ' . $package['primary'] . ";\n";
		$lines[3] = '@brand-info:        ' . $package['info'] . ";\n";
		$lines[4] = '@brand-success:     ' . $package['success'] . ";\n";
		$lines[5] = '@brand-warning:     ' . $package['warning'] . ";\n";
		$lines[6] = '@brand-danger:      ' . $package['danger'] . ";\n";
		$lines[7] = '@menuColor:         ' . $package['menu'] . ";\n";

		$this->file->delete($this->less);
		$this->file->put($this->less, implode($lines));
	}
1125393
public function getInstallPath(PackageInterface $package): string
    {
        $this->vendorPath = parent::getInstallPath($package);
        return $this->vendorPath;
    }
147835
public function registerPackages(array $packages)
    {
        foreach ($packages as $alias => $package) {
            $this->addPackage($alias, $package);
        }

        return $this;
    }
607164
public function setCurrentPackage($package)
    {
        if (!$package instanceof AbstractPackage) {
            $package = $this->packageResolver->getPackage($package);
        }

        $this->packageResolver->setCurrentPackage($package);

        return $this;
    }
153122
public static function create(AbstractPackage $package)
    {
        return new static(
            new ControllerResolver($package, $package->getContainer()),
            new RepositoryResolver($package, $package->getContainer()),
            new ViewResolver($package, $package->getContainer())
        );
    }