@param Composer $composer

@return SharedPackageInstallerConfig
765327
protected function setConfig(Composer $composer)
    {
        return new SharedPackageInstallerConfig(
            $composer->getConfig()->get('vendor-dir'),
            $composer->getConfig()->get('vendor-dir', 1),
            $composer->getPackage()->getExtra()
        );
    }
379914
public static function createFromComposerPackage(CompletePackageInterface $package)
    {
        $class = new self();
        $class->type = $package->getType();
        $class->name = $package->getPrettyName();
        $class->description = $package->getDescription();
        $class->authors = $package->getAuthors();
        $class->keywords = $package->getKeywords();
        if ($package->getVersion() === '9999999-dev') {
            $class->version = sprintf('%s (%s)', $package->getPrettyVersion(), substr($package->getSourceReference(), 0, 6));
        } else {
            $class->version = $package->getPrettyVersion();
        }

        return $class;
    }
1235220
public function mergePackageLoader($directory)
    {
        if ($vendor = $this->findVendor($directory)) {
            $this->mergeComposerNamespaces($vendor);
            $this->mergeComposerPsr4($vendor);
            $this->mergeComposerClassMap($vendor);
        }
    }
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);
    }
440986
private function getSuggestsFilters(Composer $composer): array
    {
        return array_map(
            function (string $package) : ViolationFilterInterface {
                return new ExactPackageFilter($package);
            },
            array_keys(
                $composer->getPackage()->getSuggests()
            )
        );
    }
80219
private function requireComposerPackage($package)
    {
        $composer = $this->findComposer();
        $process = new Process($composer.' require '.$package.''.$this->getDevOption(),
                       null, null, null, null);
        $this->output->writeln('<info>Running composer require '.$package.$this->getDevOption().'</info>');
        $process->run(function ($type, $line) {
            $this->output->write($line);
        });
    }
1203067
protected function getInstallerConfig(PackageInterface $package)
    {
        if ($this->installerConfig !== null) {
            return $this->installerConfig;
        }

        $type       = $package->getType();
        $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'];
        }

        $loader = 'mu-plugins/' . $name . '.php';

        if (!empty($extra['installer-loader'])) {
            $loader = $extra['installer-loader'];
        }

        return compact('name', 'vendor', 'type', 'loader');
    }
814025
public function activate(Composer $composer, IOInterface $io)
    {
        $this->package = $composer->getPackage();
        $this->io = $io;

        // TODO: get the project root - must be a better way to do this
        $this->projectRoot = realpath(dirname($composer->getConfig()->get('vendor-dir')));
    }
270139
public function activate(Composer $composer, IOInterface $ioc)
    {
        $installer = new Installer($ioc, $composer);
        /** @type InstallationManager $manager */
        $manager = $composer->getInstallationManager();
        $manager->addInstaller($installer);
    }
239364
public function activate(Composer $composer, IOInterface $io): void
    {
        $this->installer = new Installer($io, $composer);
        $this->vendorPath = $composer->getConfig()->get('vendor-dir');
        $composer->getInstallationManager()->addInstaller($this->installer);
    }
1320886
public function add($package)
    {
        if ((!$package instanceof PackageInterface)) {
            $name = $package;
            $package = Package::create($name);
        }

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

        return $package;
    }
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;
    }
1299066
public function package(string $vendor)
    {
        if (!array_key_exists($vendor, $this->packages)) {
            throw Exception::forPackageNotFound($vendor);
        }

        return $this->packages[$vendor];
    }
634544
private function getFilteredLinks(Composer $composer)
    {
        $links = array_values($composer->getPackage()->getRequires());

        // only pick up packages in our filter, if a filter has been set.
        if ($this->hasFilterForPackages()) {
            $packagesFilter = $this->packagesFilter;
            $links = array_filter($links, function (Link $link) use ($packagesFilter) {
                return in_array($link->getTarget(), $packagesFilter);
            });
        }

        return array_values($links);
    }
442897
public function setComposerManifest(ComposerManifestParser $composer)
    {
        $this->composer_manifest = $composer;
        $this->setDependencies($this->composer_manifest->getExtraEntry('assets-presets'));
        return $this;
    }
529481
public function installPackage($package)
    {
        // We read its composer file
        $jsonData = $this->getPackageJsonFile($package);
        // We get the package assets dirs
        $packagesAssetsDir = $this->getPackageAssetsDirs($jsonData);
        if (!is_null($packagesAssetsDir)) {
            $this->log($package->getTarget(), self::LOG_INFO, self::CODE_INSTALLING_PACKAGE);
            $this->packagesStatuses[$package->getTarget()]['extra'] = 1;
            foreach ($packagesAssetsDir as $namespace => $packageAssetsDir) {
                if (!isset($this->packagesStatuses[$package->getTarget()]['dirs'])) {
                    $this->packagesStatuses[$package->getTarget()]['dirs'] = array();
                }
                $this->packagesStatuses[$package->getTarget()]['dirs'][$namespace] = null;
                // We install each package directory
                $this->installPackageDir($package, $namespace, $packageAssetsDir);
            }
        } else {
            $this->log($package->getTarget(), self::LOG_INFO, self::CODE_NO_INSTALL);
            $this->packagesStatuses[$package->getTarget()]['extra'] = 0;
        }
    }
238049
public static function build(Composer $composer, array $defaults = array(), $io = null)
    {
        $config = self::getConfigBase($composer, $io);

        return new Config($config, $defaults);
    }