本文整理汇总了PHP中Composer\Package\PackageInterface类的典型用法代码示例。如果您正苦于以下问题:PHP PackageInterface类的具体用法?PHP PackageInterface怎么用?PHP PackageInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PackageInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPackageBasePath
/**
* {@inheritDoc}
*/
protected function getPackageBasePath(PackageInterface $package)
{
$ssp_path = '.';
$ssp_pack = $this->composer->getRepositoryManager()->getLocalRepository()->findPackage('simplesamlphp/simplesamlphp', '*');
if ($ssp_pack !== null) {
$ssp_path = $this->composer->getInstallationManager()->getInstallPath($ssp_pack);
}
$name = $package->getPrettyName();
if (!preg_match('@^.*/simplesamlphp-module-(.+)$@', $name, $matches)) {
throw new \InvalidArgumentException('Unable to install module ' . $name . ', package name must be on the form "VENDOR/simplesamlphp-module-MODULENAME".');
}
$moduleDir = $matches[1];
if (!preg_match('@^[a-z0-9_.-]*$@', $moduleDir)) {
throw new \InvalidArgumentException('Unable to install module ' . $name . ', module name must only contain characters from a-z, 0-9, "_", "." and "-".');
}
if ($moduleDir[0] === '.') {
throw new \InvalidArgumentException('Unable to install module ' . $name . ', module name cannot start with ".".');
}
/* Composer packages are supposed to only contain lowercase letters, but historically many modules have had names in mixed case.
* We must provide a way to handle those. Here we allow the module directory to be overridden with a mixed case name.
*/
$extraData = $package->getExtra();
if (isset($extraData['ssp-mixedcase-module-name'])) {
$mixedCaseModuleName = $extraData['ssp-mixedcase-module-name'];
if (!is_string($mixedCaseModuleName)) {
throw new \InvalidArgumentException('Unable to install module ' . $name . ', "ssp-mixedcase-module-name" must be a string.');
}
if (mb_strtolower($mixedCaseModuleName, 'utf-8') !== $moduleDir) {
throw new \InvalidArgumentException('Unable to install module ' . $name . ', "ssp-mixedcase-module-name" must match the package name except that it can contain uppercase letters.');
}
$moduleDir = $mixedCaseModuleName;
}
return $ssp_path . '/modules/' . $moduleDir;
}
示例2: run
function run(PackageInterface $package, $isMain = true)
{
$extra = $package->getExtra();
if (!isset($extra['bower'])) {
return;
}
if (isset($extra['bower']['dependencies']) and is_array($extra['bower']['dependencies'])) {
foreach ($extra['bower']['dependencies'] as $package => $version) {
$this->installPackage($package, $version);
}
}
if (isset($extra['bower']['files']) and is_array($extra['bower']['files'])) {
foreach ($extra['bower']['files'] as $file) {
$path = getcwd() . "/" . $file;
if (is_file($path)) {
$bower = json_decode(file_get_contents($path));
if (isset($bower->dependencies)) {
foreach ($bower->dependencies as $package => $version) {
$this->installPackage($package, $version);
}
}
} elseif ($isMain) {
throw new \OutOfRangeException("File {$file} defined in composer section extra.bower.files does not exist on path: {$path}");
}
}
}
}
示例3: getComponentPath
/**
* Gets the destination Component directory.
*
* @param PackageInterface $package
* @return string
* The path to where the final Component should be installed.
*/
public function getComponentPath(PackageInterface $package)
{
// Parse the pretty name for the vendor and package name.
$name = $prettyName = $package->getPrettyName();
if (strpos($prettyName, '/') !== false) {
list($vendor, $name) = explode('/', $prettyName);
unset($vendor);
}
// First look for an override in root package's extra, then try the package's extra
$rootPackage = $this->composer->getPackage();
$rootExtras = $rootPackage ? $rootPackage->getExtra() : array();
$customComponents = isset($rootExtras['component']) ? $rootExtras['component'] : array();
if (isset($customComponents[$prettyName]) && is_array($customComponents[$prettyName])) {
$component = $customComponents[$prettyName];
} else {
$extra = $package->getExtra();
$component = isset($extra['component']) ? $extra['component'] : array();
}
// Allow the component to define its own name.
if (isset($component['name'])) {
$name = $component['name'];
}
// Find where the package should be located.
return $this->getComponentDir() . DIRECTORY_SEPARATOR . $name;
}
示例4: doUpdate
/**
* {@inheritDoc}
*/
public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
{
$ref = escapeshellarg($target->getSourceReference());
$path = escapeshellarg($path);
$this->io->write(" Checking out " . $target->getSourceReference());
$this->process->execute(sprintf('cd %s && git fetch && git checkout %2$s && git reset --hard %2$s', $path, $ref), $ignoredOutput);
}
示例5: validatePackage
/**
* @param PackageInterface $package
* @param bool $allowDevMaster
*
* @return \string[]
*/
public function validatePackage(PackageInterface $package, $allowDevMaster = false)
{
$errors = [];
$versionParser = new VersionParser();
/** @noinspection ExceptionsAnnotatingAndHandlingInspection */
$devMaster = new Constraint('==', $versionParser->normalize('dev-master'));
foreach ($package->getRequires() as $link) {
$linkConstraint = $link->getConstraint();
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $link->getTarget())) {
continue;
}
if ($linkConstraint->matches($devMaster)) {
if ($allowDevMaster) {
continue;
}
$errors[] = sprintf('Package "%s" is required with branch constraint %s', $link->getTarget(), $linkConstraint->getPrettyString());
}
$constraints = [$linkConstraint];
if ($linkConstraint instanceof MultiConstraint) {
$constraints = (new ConstraintAccessor($linkConstraint))->getConstraints();
}
foreach ($constraints as $constraint) {
if ('dev-' === substr($constraint->getPrettyString(), 0, 4)) {
$errors[] = sprintf('Package "%s" is required with branch constraint %s', $link->getTarget(), $linkConstraint->getPrettyString());
}
}
}
return $errors;
}
示例6: getPackageBasePath
/**
* {@inheritDoc}
*
* @throws \RuntimeException
*/
public function getPackageBasePath(PackageInterface $package)
{
$extra = $package->getExtra();
if (!empty($extra['installer-name'])) {
return 'plugins/' . $extra['installer-name'];
}
$primaryNS = null;
$autoLoad = $package->getAutoload();
foreach ($autoLoad as $type => $pathMap) {
if ($type !== 'psr-4') {
continue;
}
$count = count($pathMap);
if ($count === 1) {
$primaryNS = key($pathMap);
break;
}
$matches = preg_grep('#^(\\./)?src/?$#', $pathMap);
if ($matches) {
$primaryNS = key($matches);
break;
}
foreach (['', '.'] as $path) {
$key = array_search($path, $pathMap, true);
if ($key !== false) {
$primaryNS = $key;
}
}
break;
}
if (!$primaryNS) {
throw new \RuntimeException('Unable to get CakePHP plugin name.');
}
return 'plugins/' . trim(str_replace('\\', '/', $primaryNS), '/');
}
示例7: getInstallPath
/**
* {@inheritdoc}
*/
public function getInstallPath(PackageInterface $package)
{
$this->initializeVendorDir();
$targetDir = $package->getTargetDir();
list(, $name) = explode('/', $package->getPrettyName(), 2);
return ($this->vendorDir ? $this->vendorDir . '/' : '') . $name . ($targetDir ? '/' . $targetDir : '');
}
示例8: getInstallPath
public function getInstallPath(PackageInterface $package)
{
$packageName = $package->getPrettyName();
$packageExtra = $this->composer->getPackage()->getExtra();
if (false === array_key_exists('wordpress-install-dir', $packageExtra)) {
return parent::getInstallPath($package);
}
$installDirs = $packageExtra['wordpress-install-dir'];
if (false === is_array($installDirs)) {
throw new InvalidPackageException(['Installation directory must be a key value array of packages and install directories.'], [], [$installDirs]);
}
if (false === array_key_exists($packageName, $installDirs)) {
throw new InvalidPackageException(['Installation directory must be a key value array of packages and install directories.'], [], [$installDirs]);
}
$packageInstallDir = $installDirs[$packageName];
$installDirCount = 0;
foreach ($installDirs as $installDir) {
if ($installDir === $packageInstallDir) {
$installDirCount++;
}
}
if ($installDirCount > 1) {
throw new InvalidPackageException(['Two packages cannot have the same install directory'], [], $installDirs);
}
return $installDirs[$packageName];
}
示例9: getCoreInstallPath
protected function getCoreInstallPath(PackageInterface $package)
{
$type = $package->getType();
$prettyName = $package->getPrettyName();
if (strpos($prettyName, '/') !== false) {
list($vendor, $name) = explode('/', $prettyName);
} else {
$vendor = '';
$name = $prettyName;
}
$availableVars = compact('name', 'vendor', 'type');
$extra = $package->getExtra();
if (!empty($extra['installer-name'])) {
$availableVars['name'] = $extra['installer-name'];
}
if ($this->composer->getPackage()) {
$extra = $this->composer->getPackage()->getExtra();
if (!empty($extra['installer-paths'])) {
$customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type);
if ($customPath !== false) {
return $this->templatePath($customPath, $availableVars);
}
}
}
$path = self::DEFAULT_TARGET_PATH;
return $this->templatePath($path, $availableVars);
}
示例10: getPackageBasePath
/**
* @param PackageInterface $package
*
* @return string
*/
public function getPackageBasePath(PackageInterface $package)
{
$extra = $package->getExtra();
print_r($extra);
// get dependency glue packages
return parent::getPackageBasePath($package);
}
示例11: getPackageInstallPath
public static function getPackageInstallPath(PackageInterface $package, Composer $composer)
{
$prettyName = $package->getPrettyName();
if (strpos($prettyName, '/') !== false) {
list($vendor, $name) = explode('/', $prettyName);
} else {
$vendor = '';
$name = $prettyName;
}
$availableVars = compact('name', 'vendor');
$extra = $package->getExtra();
if (!empty($extra['installer-name'])) {
$availableVars['name'] = $extra['installer-name'];
}
if ($composer->getPackage()) {
$extra = $composer->getPackage()->getExtra();
if (!empty($extra['installer-paths'])) {
$customPath = self::mapCustomInstallPaths($extra['installer-paths'], $prettyName);
if (false !== $customPath) {
return self::templatePath($customPath, $availableVars);
}
}
}
return NULL;
}
示例12: getPackageBasePath
protected function getPackageBasePath(PackageInterface $package)
{
if (!$this->supports($package->getType())) {
throw new \InvalidArgumentException("Package type [{$type}] is not supported");
}
return self::$allowedTypes[$package->getType()] . '/' . $package->getPrettyName();
}
示例13: getInstallPath
/**
* {@inheritDoc}
*/
public function getInstallPath(PackageInterface $package)
{
$installationDir = false;
$prettyName = $package->getPrettyName();
if ($this->composer->getPackage()) {
$topExtra = $this->composer->getPackage()->getExtra();
if (!empty($topExtra['wordpress-install-dir'])) {
$installationDir = $topExtra['wordpress-install-dir'];
if (is_array($installationDir)) {
$installationDir = empty($installationDir[$prettyName]) ? false : $installationDir[$prettyName];
}
}
}
$extra = $package->getExtra();
if (!$installationDir && !empty($extra['wordpress-install-dir'])) {
$installationDir = $extra['wordpress-install-dir'];
}
if (!$installationDir) {
$installationDir = 'wordpress';
}
if (!empty(self::$_installedPaths[$installationDir]) && $prettyName !== self::$_installedPaths[$installationDir]) {
throw new \InvalidArgumentException('Two packages cannot share the same directory!');
}
self::$_installedPaths[$installationDir] = $prettyName;
return $installationDir;
}
示例14: getInstallPath
/**
* {@inheritDoc}
*/
public function getInstallPath(PackageInterface $package)
{
$prettyName = explode('/', $package->getPrettyName());
$devName = $prettyName[0];
$themeName = $prettyName[1];
return 'theme/' . $devName . '/' . $themeName . '/';
}
示例15: getInstallPath
/**
* {@inheritDoc}
*/
public function getInstallPath(PackageInterface $package)
{
if (substr($package->getPrettyName(), 0, 23) != 'phpdocumentor/template-') {
throw new \InvalidArgumentException('Unable to install template, phpdocumentor templates should always start their package name with "phpdocumentor/template."');
}
return 'data/templates/' . substr($package->getPrettyName(), 23);
}