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


PHP PackageInterface::setExtra方法代碼示例

本文整理匯總了PHP中Composer\Package\PackageInterface::setExtra方法的典型用法代碼示例。如果您正苦於以下問題:PHP PackageInterface::setExtra方法的具體用法?PHP PackageInterface::setExtra怎麽用?PHP PackageInterface::setExtra使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Composer\Package\PackageInterface的用法示例。


在下文中一共展示了PackageInterface::setExtra方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setInstallerName

 /**
  * Set installer-name based on namespace for the source path checking in
  * following order:
  *
  * - With only one autoload path the namespace for that path will be used.
  * - With multiple paths if path 'src' exists it's namespace will be used.
  * - With two autoload paths provided, the namespace of path other than
  *   'tests' will be used.
  *
  * No installer-name is set if PSR-4 autoload block is not found or if none
  * of the above conditions are met.
  *
  * @param PackageInterface $package
  */
 protected function setInstallerName(PackageInterface $package)
 {
     $primaryNS = null;
     $autoLoad = $package->getAutoload();
     foreach ($autoLoad as $type => $typeConfig) {
         if ($type !== 'psr-4') {
             continue;
         }
         $count = count($typeConfig);
         if ($count === 1) {
             $primaryNS = key($typeConfig);
             break;
         }
         $matches = preg_grep('#^(\\./)?src/?$#', $typeConfig);
         if ($matches) {
             $primaryNS = key($matches);
             break;
         }
         if ($count === 2) {
             reset($typeConfig);
             if (preg_match('#^(\\./)?tests/?$#', current($typeConfig))) {
                 next($typeConfig);
             }
             $primaryNS = key($typeConfig);
             break;
         }
         break;
     }
     if ($primaryNS) {
         $package->setExtra(array('installer-name' => trim(str_replace('\\', '/', $primaryNS), '/')));
     }
 }
開發者ID:nooshin-mirzadeh,項目名稱:web_2.0_benchmark,代碼行數:46,代碼來源:CakePHPInstaller.php

示例2: setInstallerName

 /**
  * Set installer-name based on namespace for the source path
  *
  * With one autoload path this will be used as installer-name.
  * With two autoload paths the first non `tests` foldername will be set.
  * If more then 2 autoload paths are provided, installer-name will only be
  * set for if `src` folder is used.
  *
  * @param PackageInterface $package
  */
 protected function setInstallerName(PackageInterface $package)
 {
     $autoLoad = $package->getAutoload();
     foreach ($autoLoad as $type => $typeConfig) {
         if ($type !== 'psr-4') {
             continue;
         }
         $count = count($typeConfig);
         foreach ($typeConfig as $namespace => $path) {
             if ($path === 'tests') {
                 continue;
             }
             if ($count > 2 && $path !== 'src') {
                 continue;
             }
             $installerName = trim(str_replace('\\', '/', $namespace), '/');
             $package->setExtra(array('installer-name' => $installerName));
         }
         break;
     }
 }
開發者ID:grBro,項目名稱:taskmanager,代碼行數:31,代碼來源:CakePHPInstaller.php

示例3: addMainFiles

 /**
  * Adds the main file definitions from the root package.
  *
  * @param Composer         $composer
  * @param PackageInterface $package
  * @param string           $section
  */
 public static function addMainFiles(Composer $composer, PackageInterface $package, $section = 'asset-main-files')
 {
     if ($package instanceof \Composer\Package\Package) {
         $packageExtra = $package->getExtra();
         $extra = $composer->getPackage()->getExtra();
         if (isset($extra[$section])) {
             foreach ($extra[$section] as $packageName => $files) {
                 if ($packageName === $package->getName()) {
                     $packageExtra['bower-asset-main'] = $files;
                     break;
                 }
             }
         }
         $package->setExtra($packageExtra);
     }
     return $package;
 }
開發者ID:MvegaR,項目名稱:ingSotfware,代碼行數:24,代碼來源:AssetPlugin.php


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