Unlock a locked package version.

@param PackageInterface $package The repository holding the packages to convert.

@return ComposerJson
190396
public function lockPackage(PackageInterface $package)
    {
        $name = $package->getPrettyName();
        $lock = 'extra/tenside/version-locks/' . $this->escape($name);

        // Nothing to do?
        if ($this->has($lock)) {
            return $this;
        }

        if ($this->isRequiring($name)) {
            $this->set($lock, $this->getRequire($name));
        } else {
            $this->set($lock, false);
        }

        $this->requirePackage(
            $package->getPrettyName(),
            PackageConverter::convertPackageVersion($package, true)
        );

        return $this;
    }
427181
public static function getInstalledVersion($package)
    {
        $composer = ComposerInformation::getLock();

        $data = ArrayHelper::query($composer['packages'], ['name' => $package]);

        if (isset($data[0]['version'])) {
            return $data[0]['version'];
        }

        return null;
    }
931532
public function fromLock($lockPath)
    {
        if (!is_file($lockPath)) {
            throw new ComposerFileDoesNotExistsException($lockPath);
        }

        $file = new SplFileInfo($lockPath, null, null);
        $decodedData = json_decode($file->getContents(), true);

        if (json_last_error() != JSON_ERROR_NONE) {
            throw new ComposerFileIsInvalidException($lockPath);
        }

        $packages = array();
        foreach ($decodedData['packages'] as $package) {
            $packages[] = Package::fromArray($package);
        }

        $devPackages = array();
        foreach ($decodedData['packages-dev'] as $package) {
            $devPackages[] = Package::fromArray($package);
        }

        return new Composer($packages, $devPackages, true);
    }
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;
    }
1001152
public function getInstallPath(PackageInterface $package)
    {
        if ($this->solver->isSharedPackage($package)) {
            return $this->symlinkInstaller->getInstallPath($package);
        }

        return $this->defaultInstaller->getInstallPath($package);
    }
742359
protected function getSourceStandards(PackageInterface $package)
    {
        $basePath = $this->getInstallPath($package);

        return $this->findStandards($basePath);
    }
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));
            }
        }
    }
1157684
public function convertPackageToArray(PackageInterface $package, PackageInterface $upgrade = null)
    {
        $name = $package->getPrettyName();
        $data = new JsonArray([
            'name'       => $name,
            'version'    => $this->convertPackageVersion($package),
            'constraint' => $this->getConstraint($name),
            'type'       => $package->getType(),
            'locked'     => $this->isLocked($name),
        ]);

        if (null !== ($releaseDate = $package->getReleaseDate())) {
            $data->set('time', $releaseDate->format(\DateTime::ATOM));
        }

        if (null !== $upgrade) {
            $data->set('upgrade_version', $upgrade->getPrettyVersion());
            if (null !== ($upgradeReleaseDate = $upgrade->getReleaseDate())) {
                $data->set('upgrade_time', $upgradeReleaseDate->format(\DateTime::ATOM));
            }
        }

        if ($package instanceof CompletePackageInterface) {
            $this->convertCompletePackage($package, $data);
        }

        return $data;
    }
872790
public function setPackage($package)
    {
        if ($package instanceof AbstractPackage) {
            $this->package = $package;
        } else {
            $this->package = PackageHelper::getPackage($package);
        }

        return $this;
    }
155485
public function resetPackage(WritableRepositoryInterface $repository, PackageInterface $package)
    {
        $verbosityLevel = OutputUtils::resetVerbosity($this->appIO, OutputInterface::VERBOSITY_QUIET);

        $operation = new ResetOperation($package, 'Package reset due to changes in patches configuration');

        if (!$this->packageResetStrategy->shouldAllowReset($package)) {
            OutputUtils::resetVerbosity($this->appIO, $verbosityLevel);

            throw new \Vaimo\ComposerPatches\Exceptions\PackageResetException(
                sprintf('Package reset halted due to encountering local changes: %s', $package->getName())
            );
        }

        try {
            $this->installer->install($repository, $operation);
        } catch (\Exception $exception) {
            OutputUtils::resetVerbosity($this->appIO, $verbosityLevel);

            throw $exception;
        }

        OutputUtils::resetVerbosity($this->appIO, $verbosityLevel);
    }
1290647
public static function hasExtraActivation(PackageInterface $package)
    {
        $extra = $package->getExtra();

        return isset($extra['foxy']) && true === $extra['foxy'];
    }
93826
protected function _removeAutoloader(PackageInterface $package)
    {
        $path = $this->_getAutoloaderPath($package);

        if(file_exists($path))
        {
            $contents = file_get_contents($path);

            if (strpos($contents, 'This file has been generated automatically by Composer.') !== false) {
                unlink($path);
            }
        }
    }
180014
protected function findBundleFiles(PackageInterface $package)
    {
        $installPath = $this->composer->getInstallationManager()->getInstallPath($package);

        $autoload = $package->getAutoload();
        if (isset($autoload['psr-0'])) {
            $installPath .= '/' . current($autoload['psr-0']);
        }
        if (isset($autoload['psr-4'])) {
            $installPath .= '/' . current($autoload['psr-4']);
        }

        return glob(rtrim($installPath, '/') . '/*Bundle.php');
    }
421940
protected function collectPatchesFromPackage(PackageInterface $package)
    {
        $collectedPatches = new PatchCollection();
        $extra = $package->getExtra();
        if (isset($extra['patches'])) {
            $this->io->write('<info>Gathering patches from '.$package->getName().' (extra.patches).</info>');
            $collectedPatches->merge($this->resolveExplicitList($package, $extra['patches']));
        }
        if (isset($extra['patches-file'])) {
            $this->io->write('<info>Gathering patches from '.$package->getName().' (extra.patches-file).</info>');
            $collectedPatches->merge($this->resolveJsonFile($package, $extra['patches-file']));
        }

        return $collectedPatches;
    }
99875
private function determineLockViolations(
        Composer $composer,
        CandidateInterface ...$candidates
    ): array {
        $violations = [];
        $lock       = $composer->getLocker()->getLockData();

        $lockedPackages = array_map(
            function (array $package) : string {
                return $package['name'];
            },
            $lock['packages'] ?? []
        );

        $lockedDevPackages = array_map(
            function (array $package) : string {
                return $package['name'];
            },
            $lock['packages-dev'] ?? []
        );

        foreach ($candidates as $candidate) {
            $package = $candidate->getPackage()->getName();

            if (in_array($package, $lockedDevPackages, true)) {
                $violations[] = new Violation(
                    sprintf(
                        'Code base is dependent on dev package %s.',
                        $package
                    ),
                    $candidate
                );
                continue;
            }

            if (!in_array($package, $lockedPackages, true)) {
                $violations[] = new Violation(
                    sprintf(
                        'Package is not installed: %s.',
                        $package
                    ),
                    $candidate
                );
            }
        }

        return $violations;
    }
106832
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
	{
		if (getenv('OPUS_DISABLED')) {
			parent::uninstall($repo, $package);
			return;
		}

		//
		// Return immediately if we have no information relevant to our installer
		//

		if (!$this->checkFrameworkSupport($package)) {
			return;
		}

		$this->loadInstallationMap();

		foreach ($this->installationMap as $path => $packages) {
			if (($key = array_search($package->getName(), $packages)) !== FALSE) {
				unset($this->installationMap[$path][$key]);
			}
		}

		$this->cleanup();
		$this->saveInstallationMap();

		parent::uninstall($repo, $package);
	}
1105723
public function getInstallPath(PackageInterface $package)
	{
		$prefix = mb_substr($package->getPrettyName(), 0, 23);
		if ('myadmin/template-' !== $prefix) {
			throw new \InvalidArgumentException(
				'Unable to install template, myadmin templates '
				.'should always start their package name with '
				.'"myadmin/template-"'
			);
		}
		return 'data/templates/'.mb_substr($package->getPrettyName(), 23);
	}