Exemple #1
0
 private function getPluginCommands()
 {
     $commands = array();
     $composer = $this->getComposer(false, false);
     if (null === $composer) {
         $composer = Factory::createGlobal($this->io, false);
     }
     if (null !== $composer) {
         $pm = $composer->getPluginManager();
         foreach ($pm->getPluginCapabilities('Composer\\Plugin\\Capability\\CommandProvider', array('composer' => $composer, 'io' => $this->io)) as $capability) {
             $newCommands = $capability->getCommands();
             if (!is_array($newCommands)) {
                 throw new \UnexpectedValueException('Plugin capability ' . get_class($capability) . ' failed to return an array from getCommands');
             }
             foreach ($newCommands as $command) {
                 if (!$command instanceof Command\BaseCommand) {
                     throw new \UnexpectedValueException('Plugin capability ' . get_class($capability) . ' returned an invalid value, we expected an array of Composer\\Command\\BaseCommand objects');
                 }
             }
             $commands = array_merge($commands, $newCommands);
         }
     }
     return $commands;
 }