本文整理汇总了PHP中Composer\Composer::getEventDispatcher方法的典型用法代码示例。如果您正苦于以下问题:PHP Composer::getEventDispatcher方法的具体用法?PHP Composer::getEventDispatcher怎么用?PHP Composer::getEventDispatcher使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Composer
的用法示例。
在下文中一共展示了Composer::getEventDispatcher方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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);
}
示例2: uninstall
/**
* @param array $packageNames
*
* @throws \RuntimeException
*/
public function uninstall(array $packageNames)
{
$this->logger->info('Uninstalling begin', $packageNames);
array_map(function ($name) {
if (!$this->canBeDeleted($name)) {
$errorMessage = sprintf('Package %s is not deletable', $name);
$this->logger->error($errorMessage);
throw new \RuntimeException($errorMessage);
}
}, $packageNames);
$this->maintenance->activate();
$this->removeFromComposerJson($packageNames);
$installationManager = $this->composer->getInstallationManager();
$localRepository = $this->getLocalRepository();
$this->composer->getEventDispatcher()->dispatchCommandEvent('cache-clear', false);
array_map(function ($name) use($installationManager, $localRepository) {
$package = $this->findInstalledPackage($name);
$this->scriptRunner->runUninstallScripts($package);
$installationManager->uninstall($localRepository, new UninstallOperation($package));
}, $packageNames);
$this->scriptRunner->removeCachedFiles();
$this->scriptRunner->clearApplicationCache();
$this->scriptRunner->runPlatformUpdate();
$this->scriptRunner->clearDistApplicationCache();
$this->logger->info('Packages uninstalled', $packageNames);
}
示例3: activate
/**
* Apply plugin modifications to composer
*
* @param Composer $composer
* @param IOInterface $io
*/
public function activate(Composer $composer, IOInterface $io)
{
$this->composer = $composer;
$this->io = $io;
$this->eventDispatcher = $composer->getEventDispatcher();
$this->executor = new ProcessExecutor($this->io);
$this->patches = array();
}
示例4: __construct
/**
* @param \Composer\Package\PackageInterface $package
* @param \Composer\Composer $composer
*/
public function __construct(PackageInterface $package, Composer $composer)
{
parent::__construct($composer->getEventDispatcher());
$this->_composer = $composer;
$this->_autoloader = AssetsAutoloadGenerator::getInstance();
$this->_autoloader->setGenerator(array($this, 'generate'));
$this->_package = $package;
}
示例5: getComposer
/**
* Get a Composer object.
*
* @return \Composer\Composer
*/
protected function getComposer()
{
if (!$this->composer) {
// Set working directory
chdir($this->getOption('basedir'));
// Use the factory to get a new Composer object
try {
$this->composer = Factory::create($this->getIO(), $this->getOption('composerjson'), true);
// Add the event subscriber
$this->composer->getEventDispatcher()->addSubscriber($this->app['extend.listener']);
if (!$this->app['extend.manager']->useSsl()) {
$this->setAllowSslDowngrade(true);
}
} catch (\Exception $e) {
$this->app['logger.system']->critical($e->getMessage(), ['event' => 'exception', 'exception' => $e]);
}
}
return $this->composer;
}
示例6: test_it_receives_event
public function test_it_receives_event()
{
$this->composer->getPluginManager()->addPlugin(new ChangelogsPlugin());
$initialPackage = new Package('foo/bar', '1.0.0.0', 'v1.0.0');
$initialPackage->setSourceUrl('https://github.com/foo/bar.git');
$targetPackage = new Package('foo/bar', '1.0.1.0', 'v1.0.1');
$targetPackage->setSourceUrl('https://github.com/foo/bar.git');
$operation = new UpdateOperation($initialPackage, $targetPackage);
$this->composer->getEventDispatcher()->dispatchPackageEvent(PackageEvents::POST_PACKAGE_UPDATE, false, new DefaultPolicy(false, false), new Pool(), new CompositeRepository([]), new Request(new Pool()), [$operation], $operation);
$this->composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_UPDATE_CMD);
$expectedOutput = <<<OUTPUT
Changelogs summary:
- foo/bar updated from v1.0.0 to v1.0.1
See changes: https://github.com/foo/bar/compare/v1.0.0...v1.0.1
Release notes: https://github.com/foo/bar/releases/tag/v1.0.1
OUTPUT;
$this->assertSame($expectedOutput, $this->io->getOutput());
}
示例7: getComposer
/**
* Get a Composer object.
*
* @throws \Exception
*
* @return \Composer\Composer
*/
protected function getComposer()
{
if (!$this->composer) {
// Set working directory
chdir($this->getOptions()->baseDir());
try {
// Use the factory to get a new Composer object
$this->composer = Factory::create($this->getIO(), $this->getOptions()->composerJson()->getPath(), false);
} catch (\InvalidArgumentException $e) {
throw new PackageManagerException($e->getMessage(), $e->getCode(), $e);
} catch (\Exception $e) {
$this->app['logger.system']->critical($e->getMessage(), ['event' => 'exception', 'exception' => $e]);
throw $e;
}
// Add the event subscriber
$this->composer->getEventDispatcher()->addSubscriber($this->app['extend.listener']);
if (!$this->app['extend.manager']->useSsl()) {
$this->setAllowSslDowngrade(true);
}
}
return $this->composer;
}
示例8: activate
public function activate(Composer $composer, IOInterface $io)
{
$this->composer = $composer;
$this->io = $io;
// check if there already are scripts in .profile.d, or INI files (because we got invoked before), then calculate new starting point for file names
foreach (['profileCounter' => (getenv('profile_dir_path') ?: '/dev/null') . '/[0-9][0-9][0-9]-*.sh', 'configCounter' => self::CONF_D_PATHNAME . '/[0-9][0-9][0-9]-*.ini'] as $var => $glob) {
if ($matches = glob($glob)) {
$this->{$var} = ceil(max(array_merge([$this->{$var}], array_map(function ($e) {
return explode('-', pathinfo($e, PATHINFO_FILENAME), 2)[0];
}, $matches))) / 10) + 1;
}
}
$composer->getDownloadManager()->setDownloader('heroku-sys-tar', new Downloader($io, $composer->getConfig(), $composer->getEventDispatcher()));
$composer->getInstallationManager()->addInstaller(new ComposerInstaller($io, $composer));
}
示例9: activate
/**
* {@inheritdoc}
*/
public function activate(Composer $composer, IOInterface $io)
{
if (!$this->puliRunner) {
try {
// Add Composer's bin directory in case the "puli" executable is
// installed with Composer
$this->puliRunner = new PuliRunner($composer->getConfig()->get('bin-dir'));
} catch (RuntimeException $e) {
$io->writeError('<warn>' . $e->getMessage() . '</warn>');
// Don't activate the plugin if Puli cannot be run
return;
}
}
$composer->getEventDispatcher()->addSubscriber($this);
}
示例10: activate
/**
* Set hoa\core require in last position.
*
* @param Composer $composer composer
* @param IOInterface $io io
*/
public function activate(Composer $composer, IOInterface $io)
{
$composer->setAutoloadGenerator(new AutoloadGenerator($composer->getEventDispatcher()));
}
示例11: activate
/**
* {@inheritdoc}
*/
public function activate(Composer $composer, IOInterface $io)
{
$composer->getEventDispatcher()->addSubscriber($this);
}
示例12: activate
/**
* @inheritdoc
*/
public function activate(Composer $composer, IOInterface $io)
{
$installer = new Installer();
$composer->getEventDispatcher()->addSubscriber($installer);
}
示例13: activate
public function activate(Composer $composer, IOInterface $io)
{
$composer->getDownloadManager()->setDownloader('heroku-sys-tar', new Downloader($io, $composer->getConfig(), $composer->getEventDispatcher()));
$composer->getInstallationManager()->addInstaller(new ComposerInstaller($io, $composer));
}
示例14: create
/**
* Create Installer
*
* @param IOInterface $io
* @param Composer $composer
* @return Installer
*/
public static function create(IOInterface $io, Composer $composer)
{
return new static($io, $composer->getConfig(), $composer->getPackage(), $composer->getDownloadManager(), $composer->getRepositoryManager(), $composer->getLocker(), $composer->getInstallationManager(), $composer->getEventDispatcher(), $composer->getAutoloadGenerator());
}
示例15: activate
/**
* Apply plugin modifications to Composer
*
* @param Composer $composer
* @param IOInterface $io
*/
public function activate(Composer $composer, IOInterface $io)
{
$this->composer = $composer;
$this->generator = new AutoloadGenerator($composer->getEventDispatcher(), $io);
}