本文整理汇总了PHP中Composer\Composer::getInstallationManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Composer::getInstallationManager方法的具体用法?PHP Composer::getInstallationManager怎么用?PHP Composer::getInstallationManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Composer
的用法示例。
在下文中一共展示了Composer::getInstallationManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* {@inheritdoc}
*/
public function __construct(Composer $composer = null, IOInterface $io = null)
{
$this->composer = isset($composer) ? $composer : new Composer();
$this->io = isset($io) ? $io : new NullIO();
$this->fs = new Filesystem();
$this->installationManager = $this->composer->getInstallationManager();
}
示例2: __invoke
/**
* @param PackageEvent $event
*/
public function __invoke(PackageEvent $event)
{
$publicPath = sprintf('%s/public', $this->projectPath);
if (!is_dir($publicPath)) {
// No public path in the project; nothing to remove
return;
}
$gitignoreFile = sprintf('%s/.gitignore', $publicPath);
if (!file_exists($gitignoreFile)) {
// No .gitignore rules; nothing to remove
return;
}
$package = $event->getOperation()->getPackage();
$installer = $this->composer->getInstallationManager();
$packagePath = $installer->getInstallPath($package);
$packageConfigPath = sprintf('%s/config/module.config.php', $packagePath);
if (!file_exists($packageConfigPath)) {
// No module configuration defined; nothing to remove
return;
}
$packageConfig = (include $packageConfigPath);
if (!is_array($packageConfig) || !isset($packageConfig['asset_manager']['resolver_configs']['paths']) || !is_array($packageConfig['asset_manager']['resolver_configs']['paths'])) {
// No assets defined; nothing to remove
return;
}
$this->gitignore = $this->fetchIgnoreRules($gitignoreFile);
$paths = $packageConfig['asset_manager']['resolver_configs']['paths'];
foreach ($paths as $path) {
$this->removeAssets($path, $publicPath);
}
file_put_contents($gitignoreFile, implode("\n", $this->gitignore));
}
示例3: activate
public function activate(Composer $composer, IOInterface $io)
{
// Add the Innomatic legacy platform installer
$composer->getInstallationManager()->addInstaller(new LegacyPlatformInstaller($io, $composer));
// Add the Innomatic legacy application installer
$composer->getInstallationManager()->addInstaller(new LegacyApplicationInstaller($io, $composer));
}
示例4: checkPatches
/**
* Before running composer install,
* @param Event $event
*/
public function checkPatches(Event $event)
{
try {
$repositoryManager = $this->composer->getRepositoryManager();
$localRepository = $repositoryManager->getLocalRepository();
$installationManager = $this->composer->getInstallationManager();
$packages = $localRepository->getPackages();
$tmp_patches = $this->grabPatches();
if ($tmp_patches == FALSE) {
$this->io->write('<info>No patches supplied.</info>');
return;
}
foreach ($packages as $package) {
$extra = $package->getExtra();
$patches = isset($extra['patches']) ? $extra['patches'] : array();
$tmp_patches = array_merge_recursive($tmp_patches, $patches);
}
// Remove packages for which the patch set has changed.
foreach ($packages as $package) {
if (!$package instanceof AliasPackage) {
$package_name = $package->getName();
$extra = $package->getExtra();
$has_patches = isset($tmp_patches[$package_name]);
$has_applied_patches = isset($extra['patches_applied']);
if ($has_patches && !$has_applied_patches || !$has_patches && $has_applied_patches || $has_patches && $has_applied_patches && $tmp_patches[$package_name] !== $extra['patches_applied']) {
$uninstallOperation = new UninstallOperation($package, 'Removing package so it can be re-installed and re-patched.');
$this->io->write('<info>Removing package ' . $package_name . ' so that it can be re-installed and re-patched.</info>');
$installationManager->uninstall($localRepository, $uninstallOperation);
}
}
}
} catch (\LogicException $e) {
return;
}
}
示例5: testActivateAddsInstallerSuccessfully
public function testActivateAddsInstallerSuccessfully()
{
$plugin = new Plugin();
$plugin->activate($this->composer, $this->io);
$installer = $this->composer->getInstallationManager()->getInstaller('git-hook');
// Ensure the installer was added.
$this->assertInstanceOf('BernardoSilva\\GitHooksInstallerPlugin\\Composer\\Installer', $installer);
}
示例6: activate
/**
* Apply plugin modifications to composer
*
* @param \Composer\Composer $composer
* @param \Composer\IO\IOInterface $io
*/
public function activate(\Composer\Composer $composer, \Composer\IO\IOInterface $io)
{
$core_installer_v7 = new FrameworkInstaller($io, $composer);
$composer->getInstallationManager()->addInstaller($core_installer_v7);
$core_installer_v8 = new FrameworkInstallerV8($io, $composer);
$composer->getInstallationManager()->addInstaller($core_installer_v8);
$module_installer = new ModuleInstallerV7($io, $composer);
$composer->getInstallationManager()->addInstaller($module_installer);
}
示例7: __construct
/**
* {@inheritdoc}
*/
public function __construct(Composer $composer = null, IOInterface $io = null)
{
$this->composer = isset($composer) ? $composer : new Composer();
$this->io = isset($io) ? $io : new NullIO();
$this->fs = new Filesystem();
$this->installationManager = $this->composer->getInstallationManager();
// TODO: Break compatibility and expect in interface
$args = func_get_args();
$this->options = count($args) > 2 && is_array($args[2]) ? $args[2] : array();
}
示例8: registerLoader
private function registerLoader()
{
$package = $this->composer->getPackage();
$generator = $this->composer->getAutoloadGenerator();
$packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
$packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
$map = $generator->parseAutoloads($packageMap, $package);
$this->loader = $generator->createLoader($map);
$this->loader->register();
}
示例9: getInstallPathsFromPackages
/**
* Retrieve install paths from package installers.
*
* @param \Composer\Package\PackageInterface[] $packages
*
* @return string[]
*/
protected function getInstallPathsFromPackages(array $packages)
{
/** @var \Composer\Installer\InstallationManager $installationManager */
$installationManager = $this->composer->getInstallationManager();
$paths = array();
foreach ($packages as $package) {
$paths[] = $installationManager->getInstallPath($package);
}
return $this->absolutePaths($paths);
}
示例10: setUp
public function setUp()
{
$this->projectRoot = vfsStream::setup('project');
$this->installer = new ComponentInstaller(vfsStream::url('project'));
$this->composer = $this->prophesize(Composer::class);
$this->io = $this->prophesize(IOInterface::class);
$this->installer->activate($this->composer->reveal(), $this->io->reveal());
$this->installationManager = $this->prophesize(InstallationManager::class);
$this->composer->getInstallationManager()->willReturn($this->installationManager->reveal());
}
示例11: activate
/**
* {@inheritDoc}
*/
public function activate(Composer $composer, IOInterface $io)
{
$filesystem = new Filesystem();
$composer->getInstallationManager()->addInstaller(new CoreInstaller($composer, $filesystem, new CoreInstaller\GetTypo3OrgService($io)));
$composer->getInstallationManager()->addInstaller(new ExtensionInstaller($composer, $filesystem));
$cache = null;
if ($composer->getConfig()->get('cache-files-ttl') > 0) {
$cache = new Cache($io, $composer->getConfig()->get('cache-files-dir'), 'a-z0-9_./');
}
$composer->getDownloadManager()->setDownloader('t3x', new Downloader\T3xDownloader($io, $composer->getConfig(), null, $cache));
}
示例12: findBundleFiles
/**
* This method tries the find the BundleFile in the root of
* the given package. At this moment we don't support bundles
* that don't have the Bundle file in the package root.
*/
protected function findBundleFiles(PackageInterface $package)
{
$installPath = $this->composer->getInstallationManager()->getInstallPath($package);
$autoload = $package->getAutoload();
if (isset($autoload['psr-0'])) {
$installPath .= '/' . current($autoload['psr-0']);
}
if (isset($autoload['psr-4'])) {
$installPath .= '/' . current($autoload['psr-4']);
}
return glob(rtrim($installPath, '/') . '/*Bundle.php');
}
示例13: dumpAutoloads
/**
* @param bool $optimize
* @param bool $reload
*/
protected function dumpAutoloads($optimize = true, $reload = false)
{
if ($reload) {
$this->composer = Factory::create($this->io, null, $this->disablePluginsByDefault);
}
$config = $this->composer->getConfig();
$generator = $this->composer->getAutoloadGenerator();
$installationManager = $this->composer->getInstallationManager();
$localRepository = $this->composer->getRepositoryManager()->getLocalRepository();
$package = $this->composer->getPackage();
$generator->dump($config, $localRepository, $package, $installationManager, 'composer', $optimize);
$this->info('Composer DumpAutoloads Completed!');
}
示例14: __construct
/**
* @param string $baseDir Root directory of composer package.
*/
public function __construct($baseDir)
{
$this->baseDir = $baseDir;
$io = new NullIO();
$this->composer = (new Factory())->createComposer($io, $baseDir . '/composer.json', true, $baseDir, false);
$generator = new AutoloadGenerator($this->composer->getEventDispatcher(), $io);
$generator->setDevMode(true);
$packages = $this->composer->getRepositoryManager()->getLocalRepository()->getPackages();
$packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $this->composer->getPackage(), $packages);
$packageMap[0][1] = $baseDir;
// To make root package paths absolute too.
$autoloads = $generator->parseAutoloads($packageMap, $this->composer->getPackage());
$this->classLoader = $generator->createLoader($autoloads);
}
示例15: checkPatches
/**
* Before running composer install,
* @param Event $event
*/
public function checkPatches(Event $event)
{
try {
$repositoryManager = $this->composer->getRepositoryManager();
$localRepository = $repositoryManager->getLocalRepository();
$installationManager = $this->composer->getInstallationManager();
$packages = $localRepository->getPackages();
$tmp_patches = array();
// First, try to get the patches from the root composer.json.
$extra = $this->composer->getPackage()->getExtra();
if (isset($extra['patches'])) {
$this->io->write('<info>Gathering patches for root package.</info>');
$tmp_patches = $extra['patches'];
} else {
if (isset($extra['patches-file'])) {
$this->io->write('<info>Gathering patches from patch file.</info>');
$patches = file_get_contents($extra['patches-file']);
$patches = json_decode($patches, TRUE);
if (isset($patches['patches'])) {
$tmp_patches = $patches['patches'];
}
} else {
// @todo: should we throw an exception here?
return;
}
}
foreach ($packages as $package) {
$extra = $package->getExtra();
$patches = isset($extra['patches']) ? $extra['patches'] : array();
$tmp_patches = array_merge_recursive($tmp_patches, $patches);
}
// Remove packages for which the patch set has changed.
foreach ($packages as $package) {
if (!$package instanceof AliasPackage) {
$package_name = $package->getName();
$extra = $package->getExtra();
$has_patches = isset($tmp_patches[$package_name]);
$has_applied_patches = isset($extra['patches_applied']);
if ($has_patches && !$has_applied_patches || !$has_patches && $has_applied_patches || $has_patches && $has_applied_patches && $tmp_patches[$package_name] !== $extra['patches_applied']) {
$uninstallOperation = new UninstallOperation($package, 'Removing package so it can be re-installed and re-patched.');
$this->io->write('<info>Removing package ' . $package_name . ' so that it can be re-installed and re-patched.</info>');
$installationManager->uninstall($localRepository, $uninstallOperation);
}
}
}
} catch (\LogicException $e) {
return;
}
}