/** * Rebuild the puli dependencies for symfony container. */ protected function rebuild(InputInterface $input, OutputInterface $output) { $puli = new Puli(Path::join([getcwd(), NANBANDO_DIR])); $puli->start(); /** @var EmbeddedComposerInterface $embeddedComposer */ $embeddedComposer = $this->getApplication()->getEmbeddedComposer(); $packageManager = $puli->getPackageManager(); $io = new ConsoleIO($input, $output, $this->getApplication()->getHelperSet()); $composer = $embeddedComposer->createComposer($io); $installationManager = $composer->getInstallationManager(); $rootPackage = $composer->getPackage(); $repository = $composer->getRepositoryManager()->getLocalRepository(); $packages = []; foreach ($repository->getPackages() as $package) { $packages[$package->getName()] = $package; } foreach ($rootPackage->getRequires() as $require) { if (!array_key_exists($require->getTarget(), $packages)) { continue; } $packageManager->installPackage(Path::normalize($installationManager->getInstallPath($packages[$require->getTarget()])), $require->getTarget(), 'nanbando'); } $filesystem = new Filesystem(); $filesystem->remove(Path::join([getcwd(), NANBANDO_DIR, '.puli'])); $discoveryManager = $puli->getDiscoveryManager(); if (!$discoveryManager->hasRootTypeDescriptor('nanbando/bundle')) { $discoveryManager->addRootTypeDescriptor(new BindingTypeDescriptor(new BindingType('nanbando/bundle')), 0); } $discoveryManager->clearDiscovery(); $discoveryManager->buildDiscovery(); $filesystem = new Filesystem(); $filesystem->remove(Path::join([getcwd(), NANBANDO_DIR, 'app', 'cache'])); }
public function testGetPackageManagerInGlobalContext() { $this->puli->start(); $this->assertNull($this->puli->getPackageManager()); }