當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Package\PackageInterface類代碼示例

本文整理匯總了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;
 }
開發者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


注:本文中的Composer\Package\PackageInterface類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。