本文整理汇总了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), '/')));
}
}
示例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;
}
}
示例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;
}