本文整理汇总了PHP中Composer\Installer\InstallationManager::getInstallPath方法的典型用法代码示例。如果您正苦于以下问题:PHP InstallationManager::getInstallPath方法的具体用法?PHP InstallationManager::getInstallPath怎么用?PHP InstallationManager::getInstallPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Installer\InstallationManager
的用法示例。
在下文中一共展示了InstallationManager::getInstallPath方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mirrorDirectory
/**
* @param string $packageName
* @param string $sourceDirectory
* @param string $targetDirectory
*/
protected static function mirrorDirectory($packageName, $sourceDirectory, $targetDirectory)
{
$packages = static::$localRepository->findPackages($packageName, null);
foreach ($packages as $package) {
if (static::$installationManager->getInstaller($package->getType())->isInstalled(static::$localRepository, $package)) {
static::getFileSystem()->mirror(static::$installationManager->getInstallPath($package) . '/' . ltrim($sourceDirectory, '/'), $targetDirectory, null, ['copy_on_windows']);
return;
}
}
}
示例2: getInstallPath
/**
* Return the install path based on package type.
*
* @param PackageInterface $package
* @return string
*/
public function getInstallPath(PackageInterface $package)
{
$path = $this->installManager->getInstallPath($package);
if (!$this->filesystem->isAbsolutePath($path)) {
return realpath('.') . DIRECTORY_SEPARATOR . rtrim($path, '/');
}
return $path;
}
示例3: executeBatchCommand
/**
* @param PackageInterface[] $packages
* @param string $command
*
* @return string
*/
protected function executeBatchCommand(array $packages, $command)
{
$paths = [];
foreach ($packages as $package) {
$paths[] = $this->installationManager->getInstallPath($package);
}
$commands = $this->makeCommands($paths, $command);
$output = '';
foreach ($commands as $command) {
$output .= $this->runCommand($command);
}
return $output;
}
示例4: getVendorDir
/**
* Retrieves the given package's vendor directory, where it's installed.
*
* @param array $package
* The package to retrieve the vendor directory for.
* @return string
*/
public function getVendorDir(array $package)
{
// The root package vendor directory is not handled by getInstallPath().
if (isset($package['is-root']) && $package['is-root'] === true) {
$path = getcwd();
if (!file_exists($path . DIRECTORY_SEPARATOR . 'composer.json')) {
for ($temp = __DIR__; strlen($temp) > 3; $temp = dirname($temp)) {
if (file_exists($temp . DIRECTORY_SEPARATOR . 'composer.json')) {
$path = $temp;
}
}
}
return $path;
}
if (!isset($package['version'])) {
$package['version'] = '1.0.0';
}
$loader = new ArrayLoader();
$completePackage = $loader->load($package);
return $this->installationManager->getInstallPath($completePackage);
}
示例5: buildPackageMap
public function buildPackageMap(InstallationManager $installationManager, PackageInterface $mainPackage, array $packages)
{
// build package => install path map
$packageMap = array(array($mainPackage, ''));
foreach ($packages as $package) {
if ($package instanceof AliasPackage) {
continue;
}
$this->validatePackage($package);
$packageMap[] = array($package, $installationManager->getInstallPath($package));
}
return $packageMap;
}
示例6: buildPackageMap
public function buildPackageMap(InstallationManager $installationManager, PackageInterface $mainPackage, array $packages)
{
// build package => install path map
$packageMap = array();
$packages[] = $mainPackage;
// sort packages by dependencies
usort($packages, function (PackageInterface $a, PackageInterface $b) {
foreach (array_merge($a->getRequires(), $a->getDevRequires()) as $link) {
if (in_array($link->getTarget(), $b->getNames())) {
return 1;
}
}
foreach (array_merge($b->getRequires(), $b->getDevRequires()) as $link) {
if (in_array($link->getTarget(), $a->getNames())) {
return -1;
}
}
return strcmp($a->getName(), $b->getName());
});
foreach ($packages as $package) {
if ($package instanceof AliasPackage) {
continue;
}
if ($package === $mainPackage) {
$packageMap[] = array($mainPackage, '');
continue;
}
$packageMap[] = array($package, $installationManager->getInstallPath($package));
}
return $packageMap;
}
示例7: buildPackageMap
public function buildPackageMap(InstallationManager $installationManager, PackageInterface $mainPackage, array $packages)
{
// build package => install path map
$packageMap = array();
array_unshift($packages, $mainPackage);
foreach ($packages as $package) {
if ($package instanceof AliasPackage) {
continue;
}
if ($package === $mainPackage) {
$packageMap[] = array($mainPackage, '');
continue;
}
$packageMap[] = array($package, $installationManager->getInstallPath($package));
}
return $packageMap;
}
示例8: buildPackageMap
public function buildPackageMap(InstallationManager $installationManager, PackageInterface $mainPackage, array $packages)
{
// build package => install path map
$packageMap = array();
// add main package
$packageMap[] = array($mainPackage, '');
foreach ($packages as $package) {
$packageMap[] = array($package, $installationManager->getInstallPath($package));
}
return $packageMap;
}
示例9: testInjectModuleWithDependencies
/**
* @dataProvider dependency
*
* @param string $packageName
* @param array $enabledModules
* @param array $dependencies
* @param array $result
* @param string $autoloading classmap|files|psr-0|psr-4
* @param null|string $autoloadPath
*/
public function testInjectModuleWithDependencies($packageName, array $enabledModules, array $dependencies, array $result, $autoloading, $autoloadPath = null)
{
$installPath = 'install/path';
$modules = "\n '" . implode("',\n '", $enabledModules) . "',";
$this->createApplicationConfig('<' . "?php\nreturn [\n 'modules' => [" . $modules . "\n ],\n];");
switch ($autoloading) {
case 'classmap':
$pathToModule = 'path-classmap/to/module';
$autoload = [$autoloadPath];
break;
case 'files':
$pathToModule = 'path/to/module';
$autoload = ['path/to/module/Module.php'];
break;
case 'psr-0':
$pathToModule = sprintf('src/%s', $packageName);
$autoload = [$packageName . '\\' => 'src/'];
break;
case 'psr-4':
$pathToModule = 'src';
$autoload = [$packageName . '\\' => 'src/'];
break;
}
$dependenciesStr = $dependencies ? "'" . implode("', '", $dependencies) . "'" : '';
$this->createModuleClass(sprintf('%s/%s/Module.php', $installPath, $pathToModule), <<<CONTENT
<?php
namespace {$packageName};
class Module {
public function getModuleDependencies()
{
return [{$dependenciesStr}];
}
}
CONTENT
);
/** @var ProphecyInterface|PackageInterface $package */
$package = $this->prophesize(PackageInterface::class);
$package->getName()->willReturn('some/component');
$package->getExtra()->willReturn(['zf' => ['component' => $packageName]]);
$package->getAutoload()->willReturn([$autoloading => $autoload]);
$this->installationManager->getInstallPath(Argument::exact($package->reveal()))->willReturn(vfsStream::url('project/' . $installPath));
$operation = $this->prophesize(InstallOperation::class);
$operation->getPackage()->willReturn($package->reveal());
$event = $this->prophesize(PackageEvent::class);
$event->isDevMode()->willReturn(true);
$event->getOperation()->willReturn($operation->reveal());
$this->io->ask(Argument::that(function ($argument) use($packageName) {
if (!is_array($argument)) {
return false;
}
if (!strstr($argument[0], sprintf("Please select which config file you wish to inject '%s' into", $packageName))) {
return false;
}
if (!strstr($argument[1], 'Do not inject')) {
return false;
}
if (!strstr($argument[2], 'application.config.php')) {
return false;
}
return true;
}), 0)->willReturn(1);
$this->io->ask(Argument::that(function ($argument) {
if (!is_array($argument)) {
return false;
}
if (!strstr($argument[0], 'Remember')) {
return false;
}
return true;
}), 'n')->willReturn('n');
$this->io->write(Argument::that(function ($argument) use($packageName) {
return strstr($argument, sprintf('Installing %s from package some/component', $packageName));
}))->shouldBeCalled();
$this->assertNull($this->installer->onPostPackageInstall($event->reveal()));
$config = (include vfsStream::url('project/config/application.config.php'));
$modules = $config['modules'];
$this->assertEquals($result, $modules);
}