本文整理汇总了PHP中Composer\Config::has方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::has方法的具体用法?PHP Config::has怎么用?PHP Config::has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Config
的用法示例。
在下文中一共展示了Config::has方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* {@inheritdoc}
*/
public function init()
{
// Retrieve the configuration variables.
$this->config = $this->composer->getConfig();
if (isset($this->config)) {
if ($this->config->has('component-dir')) {
$this->componentDir = $this->config->get('component-dir');
}
}
// Get the available packages.
$allPackages = array();
/** @var \Composer\Package\Locker $locker */
$locker = $this->composer->getLocker();
if ($locker !== null && $locker->isLocked()) {
$lockData = $locker->getLockData();
$allPackages = $lockData['packages'];
// Also merge in any of the development packages.
$dev = isset($lockData['packages-dev']) ? $lockData['packages-dev'] : array();
foreach ($dev as $package) {
$allPackages[] = $package;
}
}
// Only add those packages that we can reasonably
// assume are components into our packages list
/** @var \Composer\Package\RootPackageInterface $rootPackage */
$rootPackage = $this->composer->getPackage();
$rootExtras = $rootPackage ? $rootPackage->getExtra() : array();
$customComponents = isset($rootExtras['component']) ? $rootExtras['component'] : array();
foreach ($allPackages as $package) {
$name = $package['name'];
if (isset($customComponents[$name]) && is_array($customComponents[$name])) {
$package['extra'] = array('component' => $customComponents[$name]);
$this->packages[] = $package;
} else {
$extra = isset($package['extra']) ? $package['extra'] : array();
if (isset($extra['component']) && is_array($extra['component'])) {
$this->packages[] = $package;
}
}
}
// Add the root package to the packages list.
$root = $this->composer->getPackage();
if ($root) {
$dumper = new ArrayDumper();
$package = $dumper->dump($root);
$package['is-root'] = true;
$this->packages[] = $package;
}
return true;
}
示例2: setupConfig
protected function setupConfig($config = null) {
if (!$config) {
$config = new Config();
}
if (!$config->has('home')) {
$tmpDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'cmptest-'.md5(uniqid('', true));
$config->merge(array('config' => array('home' => $tmpDir)));
}
return $config;
}
示例3: createAuthFromConfig
/**
* Create the auth params from the configuration file.
*
* @return bool
*/
private function createAuthFromConfig()
{
if (!$this->config->has('http-basic')) {
return $this->hasAuth = false;
}
$authConfig = $this->config->get('http-basic');
$host = parse_url($this->url, PHP_URL_HOST);
if (isset($authConfig[$host])) {
$this->credentials['username'] = $authConfig[$host]['username'];
$this->credentials['password'] = $authConfig[$host]['password'];
return $this->hasAuth = true;
}
return $this->hasAuth = false;
}