本文整理汇总了PHP中Composer\Package\PackageInterface类的典型用法代码示例。如果您正苦于以下问题:PHP PackageInterface类的具体用法?PHP PackageInterface怎么用?PHP PackageInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PackageInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:simplesamlphp,项目名称:composer-module-installer,代码行数:37,代码来源:ModuleInstaller.php
示例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}");
}
}
}
}
开发者ID:pipaslot,项目名称:modules,代码行数:27,代码来源:Bower.php
示例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;
}
开发者ID:robloach,项目名称:component-installer,代码行数:32,代码来源:Installer.php
示例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);
}
开发者ID:natxet,项目名称:composer,代码行数:10,代码来源:GitDownloader.php
示例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;
}
开发者ID:bankiru,项目名称:composer-dev-branch-validator,代码行数:35,代码来源:PackageValidator.php
示例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), '/');
}
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:40,代码来源:PluginInstaller.php
示例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 : '');
}
开发者ID:DYFeng,项目名称:composer-asset-plugin,代码行数:10,代码来源:AssetInstaller.php
示例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];
}
开发者ID:haydenk,项目名称:wordpress-core-installer,代码行数:26,代码来源:WordpressCoreInstaller.php
示例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);
}
开发者ID:fabian,项目名称:concrete5-composer-installers,代码行数:27,代码来源:CoreInstaller.php
示例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);
}
开发者ID:assertchris,项目名称:silverstripe-composer-glue-plugin,代码行数:12,代码来源:GluePluginInstaller.php
示例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;
}
开发者ID:mnsami,项目名称:composer-custom-directory-installer,代码行数:25,代码来源:PackageUtils.php
示例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();
}
开发者ID:kpacha,项目名称:sifo-plugin-installer,代码行数:7,代码来源:SifoInstaller.php
示例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;
}
开发者ID:UNGI-Shu,项目名称:Test,代码行数:29,代码来源:WordPressCoreInstaller.php
示例14: getInstallPath
/**
* {@inheritDoc}
*/
public function getInstallPath(PackageInterface $package)
{
$prettyName = explode('/', $package->getPrettyName());
$devName = $prettyName[0];
$themeName = $prettyName[1];
return 'theme/' . $devName . '/' . $themeName . '/';
}
开发者ID:prhost,项目名称:opencommerce-system,代码行数:10,代码来源:OpenCommerceThemeInstaller.php
示例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);
}
开发者ID:CobaltBlueDW,项目名称:oddsandends,代码行数:10,代码来源:UnifiedAssetInstaller.php
示例16: createConflictRule
protected function createConflictRule(PackageInterface $issuer, PackageInterface $provider, $reason, $reasonData = null)
{
if ($issuer === $provider) {
return null;
}
return new Rule($this->pool, array(-$issuer->getId(), -$provider->getId()), $reason, $reasonData);
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:7,代码来源:RuleSetGenerator.php
示例17: primaryNamespace
/**
* Get the primary namespace for a plugin package.
*
* @param \Composer\Package\PackageInterface $package composer object
* @return string The package's primary namespace.
* @throws \RuntimeException When the package's primary namespace cannot be determined.
*/
public function primaryNamespace($package)
{
$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(sprintf("Unable to get primary namespace for package %s." . "\nEnsure you have added proper 'autoload' section to your plugin's config", $package->getName()));
}
return trim($primaryNs, '\\');
}
开发者ID:CoreTyson,项目名称:plugin-installer,代码行数:38,代码来源:Installer.php
示例18: doUpdate
/**
* {@inheritDoc}
*/
public function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
{
GitUtil::cleanEnv();
if (!$this->hasMetadataRepository($path)) {
throw new \RuntimeException('The .git directory is missing from ' . $path . ', see https://getcomposer.org/commit-deps for more information');
}
$updateOriginUrl = false;
if (0 === $this->process->execute('git remote -v', $output, $path) && preg_match('{^origin\\s+(?P<url>\\S+)}m', $output, $originMatch) && preg_match('{^composer\\s+(?P<url>\\S+)}m', $output, $composerMatch)) {
if ($originMatch['url'] === $composerMatch['url'] && $composerMatch['url'] !== $target->getSourceUrl()) {
$updateOriginUrl = true;
}
}
$ref = $target->getSourceReference();
$this->io->writeError(" Checking out " . $ref);
$command = 'git remote set-url composer %s && git fetch composer && git fetch --tags composer';
$commandCallable = function ($url) use($command) {
return sprintf($command, ProcessExecutor::escape($url));
};
$this->gitUtil->runCommand($commandCallable, $url, $path);
if ($newRef = $this->updateToCommit($path, $ref, $target->getPrettyVersion(), $target->getReleaseDate())) {
if ($target->getDistReference() === $target->getSourceReference()) {
$target->setDistReference($newRef);
}
$target->setSourceReference($newRef);
}
if ($updateOriginUrl) {
$this->updateOriginUrl($path, $target->getSourceUrl());
}
}
开发者ID:neon64,项目名称:composer,代码行数:32,代码来源:GitDownloader.php
示例19: determineBuildNumberFromPackage
/**
* Try to determine the build number from a composer package
*
* @param \Composer\Package\PackageInterface $package
*
* @return string
*/
public static function determineBuildNumberFromPackage(PackageInterface $package)
{
if ($package->isDev()) {
$buildNumber = self::determineBuildNumberFromBrowscapBuildFile();
if (is_null($buildNumber)) {
$buildNumber = substr($package->getSourceReference(), 0, 8);
}
} else {
$installedVersion = $package->getPrettyVersion();
// SemVer supports build numbers, but fall back to just using
// version number if not available; at time of writing, composer
// did not support SemVer 2.0.0 build numbers fully:
// @see https://github.com/composer/composer/issues/2422
$plusPos = strpos($installedVersion, '+');
if ($plusPos !== false) {
$buildNumber = substr($installedVersion, $plusPos + 1);
} else {
$buildNumber = self::determineBuildNumberFromBrowscapBuildFile();
if (is_null($buildNumber)) {
$buildNumber = $installedVersion;
}
}
}
return $buildNumber;
}
开发者ID:mimmi20,项目名称:detector,代码行数:32,代码来源:ComposerHook.php
示例20: getInstallPath
/**
* Returns the installation path of a package
*
* @param PackageInterface $package Package
*
* @return string
*/
public function getInstallPath(PackageInterface $package)
{
switch ($package->getType()) {
case self::TYPE_WORDPRESS:
return 'wp';
}
}
开发者ID:symfonypress,项目名称:installer,代码行数:14,代码来源:SymfonyPressInstaller.php
注:本文中的Composer\Package\PackageInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论