예제 #1
0
 /**
  * {@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
0
 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
0
 /**
  * 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;
 }