/** * pre-fetch parallel by curl_multi */ public function onPostDependenciesSolving(Installer\InstallerEvent $ev) { $ops = $ev->getOperations(); $packages = $this->filterPackages($ops); $pluginConfig = $this->getConfig(); if (count($packages) >= $pluginConfig['minConnections']) { $downloader = new ParallelDownloader($this->io, $this->config); $downloader->download($packages, $pluginConfig); } }
public function testGetter() { $composer = $this->getMock('Composer\\Composer'); $io = $this->getMock('Composer\\IO\\IOInterface'); $policy = $this->getMock('Composer\\DependencyResolver\\PolicyInterface'); $pool = $this->getMockBuilder('Composer\\DependencyResolver\\Pool')->disableOriginalConstructor()->getMock(); $installedRepo = $this->getMockBuilder('Composer\\Repository\\CompositeRepository')->disableOriginalConstructor()->getMock(); $request = $this->getMockBuilder('Composer\\DependencyResolver\\Request')->disableOriginalConstructor()->getMock(); $operations = array($this->getMock('Composer\\DependencyResolver\\Operation\\OperationInterface')); $event = new InstallerEvent('EVENT_NAME', $composer, $io, $policy, $pool, $installedRepo, $request, $operations); $this->assertSame('EVENT_NAME', $event->getName()); $this->assertInstanceOf('Composer\\Composer', $event->getComposer()); $this->assertInstanceOf('Composer\\IO\\IOInterface', $event->getIO()); $this->assertInstanceOf('Composer\\DependencyResolver\\PolicyInterface', $event->getPolicy()); $this->assertInstanceOf('Composer\\DependencyResolver\\Pool', $event->getPool()); $this->assertInstanceOf('Composer\\Repository\\CompositeRepository', $event->getInstalledRepo()); $this->assertInstanceOf('Composer\\DependencyResolver\\Request', $event->getRequest()); $this->assertCount(1, $event->getOperations()); }
/** * Prints a list of links to package changelogs on the post-dependencies-solving event. * * @param InstallerEvent $event */ public function onPostDependenciesSolving(InstallerEvent $event) { $changelogs = []; $operations = $event->getOperations(); foreach ($operations as $operation) { if ($operation instanceof UpdateOperation) { try { $changelogs[] = self::getChangelog($operation->getInitialPackage(), $operation->getTargetPackage()); } catch (Exception\CouldNotCalculateChangelog $e) { $changelogs[] = $e->getMessage(); } } } if (!empty($changelogs)) { $this->io->write(self::PAD_STR . 'CHANGELOGS:'); foreach ($changelogs as $changelog) { $this->io->write(self::PAD_STR . self::PAD_STR . $changelog); } } }
/** * pre-fetch parallel by curl_multi */ public function onPostDependenciesSolving(Installer\InstallerEvent $ev) { if ($this->disabled) { return; } $prefetcher = new Prefetcher(); $prefetcher->fetchAllFromOperations($this->io, $this->config, $ev->getOperations()); }
public function postDependencySolve(InstallerEvent $event) { if (!$this->enabled) { return; } $extra = $event->getComposer()->getPackage()->getExtra(); $uninstall = array_get($extra, 'xpressengine-plugin.uninstall', []); foreach ($event->getOperations() as $operation) { /** @var UpdateOperation $operation */ if (is_subclass_of($operation, UpdateOperation::class) || is_subclass_of($operation, InstallOperation::class)) { $target = $operation->getInitialPackage(); if (in_array($target->getName(), $uninstall)) { throw new \Exception('xpressengine-installer: To install or update the package requested to delete is not allowed.', 66); } } } }
/** * Check that there is only 1 core package required */ public function checkCoreDependencies(InstallerEvent $event) { $installedCorePackages = array(); foreach ($event->getInstalledRepo()->getPackages() as $package) { if ($package->getType() === $this->type) { $installedCorePackages[$package->getName()] = $package; } } $operations = array_filter($event->getOperations(), function (OperationInterface $o) { return in_array($o->getJobType(), array('install', 'uninstall')); }); foreach ($operations as $operation) { $p = $operation->getPackage(); if ($p->getType() === $this->type) { switch ($operation->getJobType()) { case "uninstall": unset($installedCorePackages[$p->getName()]); break; case "install": $installedCorePackages[$p->getName()] = $p; break; } } } if (count($installedCorePackages) > 1) { throw new \RuntimeException("Cannot use more than 1 core package"); } }