Register a package for cascading configuration.

@param string $package
@param string|null $hint
@param string|null $namespace
352343
public function package($package, $hint = null, $namespace = null)
    {
        $namespace = $this->getPackageNamespace($package, $namespace);
        $hint = $hint ? $hint : $package->getPackagePath() . '/' . DIRNAME_CONFIG;
        $this->packages[] = $namespace;
        $this->addNamespace($namespace, $hint);
    }
15774
protected function requirePackage(Package $package)
    {
        $version = $this->chooseVersion($package);
        passthru(sprintf(
            'composer require %s:%s',
            $package->getName(),
            $version
        ));
        $this->comment('Package ' . $package->getName() . ' installed');
        $versions = $package->getVersions();
        $v = array_get($versions, $version);

        // Run post-process in separate command to load it with new autoloader
        passthru(sprintf(
            'php artisan package:process %s %s',
            $package->getName(),
            base64_encode(serialize($v))
        ));
    }
962332
protected function replaceInstances(string $hint): void
	{
		if(isset($this->replacers[$hint]))
		{
			$instance = $this->get($hint);

			foreach($this->replacers[$hint] as $replacer)
			{
				$replacer($instance);
			}
		}
	}
559820
public function updatePackage(PackageInterface $package, InstallerInterface $installer)
    {
        if (!$this->isPackageInstalled($package)) {
            throw new RuntimeException(sprintf('Package %s is not installed.', $package->getName()));
        }
        if (is_null($package->getRequiredVersion())) {
            $decode = $this->config->getBowerFileContent();
            if (empty($decode['dependencies']) || empty($decode['dependencies'][$package->getName()])) {
                throw new InvalidArgumentException(sprintf('Package %s not found in bower.json', $package->getName()));
            }
            $package->setRequiredVersion($decode['dependencies'][$package->getName()]);
        }

        $bower = $this->config->getPackageBowerFileContent($package);
        $package->setInfo($bower);
        $package->setVersion($bower['version']);
        $package->setRequires(isset($bower['dependencies']) ? $bower['dependencies'] : null);

        $packageTag = $this->getPackageTag($package);
        $this->output->writelnInfoPackage($package, 'validate', sprintf('%s against %s#%s', $packageTag, $package->getName(), $package->getRequiredVersion()));

        $package->setRepository($this->repository);
        if ($packageTag == $package->getVersion()) {
            // if version is fully matching, there's no need to update
            return;
        }
        $package->setVersion($packageTag);

        $this->cachePackage($package);

        $this->output->writelnUpdatingPackage($package);
        $installer->update($package);

        $overrides = $this->config->getOverrideFor($package->getName());
        if (array_key_exists('dependencies', $overrides)) {
            $dependencies = $overrides['dependencies'];
        } else {
            $dependencies = $package->getRequires();
        }
        if (!empty($dependencies)) {
            foreach ($dependencies as $name => $requiredVersion) {
                $depPackage = new Package($name, $requiredVersion);
                if (!$this->isPackageInstalled($depPackage)) {
                    $this->installPackage($depPackage, $installer, true);
                } elseif ($this->isNeedUpdate($depPackage)) {
                    $this->updatePackage($depPackage, $installer);
                }
            }
        }
    }
1189824
public function addConfigComponent(string $package, string $namespace, string $path): void
    {
        if ($this->hasPackageRepository()) {
            $this->app->make('config')->package($package, $path, $namespace);
        }
    }
936070
def fixup_namespace_packages(path_item, parent=None):
    """"""
    _imp.acquire_lock()
    try:
        for package in _namespace_packages.get(parent, ()):
            subpath = _handle_ns(package, path_item)
            if subpath:
                fixup_namespace_packages(subpath, package)
    finally:
        _imp.release_lock()
882415
public static function register(Package $package, ...$bootload): void {
        $pid = $package->pid();

        if (!$pid) {
            throw new \RuntimeException("package id of ".
                get_class($package)." can not be null");
        }
        if (self::instance()->has($pid)) {
            throw new \RuntimeException(get_class($package).
                " class package id $pid is conflicted");
        }
        self::instance()->set($pid, $package);

        self::$_bootloads[$pid] = $bootload;
    }
540399
public function packageExists($namespace, $package)
    {
        $folder = $this->vendorFolder . $namespace;
        $folderExists = file_exists($folder);

        if (!$folderExists) {
            return false;
        }

        $packageFolder = $folder . '/' . $package;
        $packageFolderExists = file_exists($packageFolder);

        return $packageFolderExists;
    }
761224
public function package($package, $hint, $namespace = null)
	{
		$namespace = $this->getPackageNamespace($package, $namespace);

		$this->packages[] = $namespace;

		// First we will simply register the namespace with the repository so that it
		// can be loaded. Once we have done that we'll register an after namespace
		// callback so that we can cascade an application package configuration.
		$this->addNamespace($namespace, $hint);

		$this->afterLoading($namespace, function($me, $group, $items) use ($package)
		{
			$env = $me->getEnvironment();

			$loader = $me->getLoader();

			return $loader->cascadePackage($env, $package, $group, $items);
		});
	}
607164
public function setCurrentPackage($package)
    {
        if (!$package instanceof AbstractPackage) {
            $package = $this->packageResolver->getPackage($package);
        }

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

        return $this;
    }
873415
public function replaceNamespace($namespace, $hints)
    {
        $this->hints[$namespace] = (array) $hints;

        // Overide Error Pages
        if ($namespace == 'errors' || $namespace == 'mails') {

            $searchPaths = array_diff($this->paths, Theme::getLaravelViewPaths());

            $addPaths = array_map(function ($path) use ($namespace) {
                return "$path/$namespace";
            }, $searchPaths);

            $this->prependNamespace($namespace, $addPaths);
        }
    }
906380
public function addRepository($path, $namespace = null)
    {
        $loader = $this->getTwig()->getLoader();

        if (false === ($loader instanceof \Twig_Loader_Filesystem)) {
            $this->throwException(500, 'Current twig loader does not support adding template repository');
        }

        /** @var \Twig_Loader_Filesystem $loader */
        $loader->addPath($path, true === isset($namespace) ? $namespace : \Twig_Loader_Filesystem::MAIN_NAMESPACE);

        return $this;
    }
1320886
public function add($package)
    {
        if ((!$package instanceof PackageInterface)) {
            $name = $package;
            $package = Package::create($name);
        }

        $this->put($package->getName(), $package);

        return $package;
    }
803657
public function package($package, $namespace = null, $path = null)
    {
        $namespace = $this->getPackageNamespace($package, $namespace);

        //
        $files = $this->app['files'];

        // In this method we will register the configuration package for the package
        // so that the configuration options cleanly cascade into the application
        // folder to make the developers lives much easier in maintaining them.
        $path = $path ?: $this->guessPackagePath();

        // Register the Package Config path.
        $config = $path .DS .'Config';

        if ($files->isDirectory($config)) {
            $this->app['config']->package($package, $config, $namespace);
        }

        // Register the Package Language path.
        $language = $path .DS .'Language';

        if ($files->isDirectory($language)) {
            $this->app['language']->package($package, $language, $namespace);
        }

        // Register the Package Views path.
        $views = $this->app['view'];

        $appView = $this->getAppViewPath($package);

        if ($files->isDirectory($appView)) {
            $views->addNamespace($package, $appView);
        }

        $viewPath = $path .DS .'Views';

        if ($files->isDirectory($viewPath)) {
            $views->addNamespace($package, $viewPath);
        }

        // Finally, register the Package Assets path.
        $this->registerPackageAssets($package, $namespace, $path);
    }
1221051
public function setConfigurationSection($package, $data)
	{
		if (!isset($this->configurationSections[$package])) {
			throw new \Exception(sprintf('There is no configuration section for package "%s"', $package));
		}

		$this->configurationSections[$package]['data'] = $data;
	}
1356025
public function prependNamespace($namespace, $hints)
    {
        $hints = (array) $hints;

        if (isset($this->hints[$namespace])) {
            $hints = array_merge($hints, $this->hints[$namespace]);
        }

        $this->hints[$namespace] = $hints;
    }
1086589
protected function addThemeNamespaceHints($namespace)
    {
        $theme = Theme::getCurrent();
        
        $hints   = array_reverse($this->hints[$namespace]);
        $hints[] = Theme::path('resources/views/vendor/'.$namespace);
        
        if (class_exists(\Caffeinated\Modules\ModulesServiceProvider::class)) {
            $hints[] = Theme::path('resources/views/modules/'.$namespace);
        }
        
        $this->hints[$namespace] = array_reverse($hints);
    }