public function testDefaultVendorDir() { $installer = $this->createInstaller(); $vendorDir = realpath(sys_get_temp_dir()) . '/composer-test/vendor/' . $this->type->getComposerVendorName(); $vendorDir = str_replace('\\', '/', $vendorDir); $installerPath = $installer->getInstallPath($this->createPackageMock('foo-asset/foo')); $installerPath = str_replace('\\', '/', $installerPath); $this->assertEquals($vendorDir . '/foo', $installerPath); $installerPath2 = $installer->getInstallPath($this->createPackageMock('foo-asset/foo/bar')); $installerPath2 = str_replace('\\', '/', $installerPath2); $this->assertEquals($vendorDir . '/foo/bar', $installerPath2); }
/** * Creates the package name with the composer prefix and the asset package name, * or only with the URL. * * @return string The package name */ protected function createPackageName() { if (null === $this->packageName) { return $this->url; } return sprintf('%s/%s', $this->assetType->getComposerVendorName(), $this->packageName); }
/** * Creates the search result item. * * @param array $item. * * @return array An array('name' => '...', 'description' => '...') */ protected function createSearchItem(array $item) { return array( 'name' => $this->assetType->getComposerVendorName() . '/' . $item['name'], 'description' => null, ); }
/** * Constructor. * * @param IOInterface $io * @param Composer $composer * @param AssetTypeInterface $assetType * @param Filesystem $filesystem */ public function __construct(IOInterface $io, Composer $composer, AssetTypeInterface $assetType, Filesystem $filesystem = null) { parent::__construct($io, $composer, $assetType->getComposerType(), $filesystem); $extra = $composer->getPackage()->getExtra(); if (!empty($extra['asset-installer-paths'][$this->type])) { $this->vendorDir = rtrim($extra['asset-installer-paths'][$this->type], '/'); } else { $this->vendorDir = rtrim($this->vendorDir . '/' . $assetType->getComposerVendorName(), '/'); } }
/** * Converts simple key of package. * * @param array $asset The asset data * @param string $assetKey The asset key of dependencies * @param array $composer The composer data * @param string $composerKey The composer key of dependencies * @param array $vcsRepos The list of new vcs configs */ protected function convertDependencies(array $asset, $assetKey, array &$composer, $composerKey, array &$vcsRepos = array()) { if (isset($asset[$assetKey]) && is_array($asset[$assetKey])) { $newDependencies = array(); foreach ($asset[$assetKey] as $dependency => $version) { list($dependency, $version) = $this->convertDependency($dependency, $version, $vcsRepos, $composer); $version = $this->assetType->getVersionConverter()->convertRange($version); if (0 !== strpos($version, $dependency)) { $newDependencies[$this->assetType->getComposerVendorName() . '/' . $dependency] = $version; } } $composer[$composerKey] = $newDependencies; } }
/** * Get the name of url file dependency. * * @param AssetTypeInterface $assetType The asset type * @param array $composer The partial composer * @param string $dependency The dependency name * * @return string The dependency name */ protected static function getUrlFileDependencyName(AssetTypeInterface $assetType, array $composer, $dependency) { $prefix = isset($composer['name']) ? substr($composer['name'], strlen($assetType->getComposerVendorName()) + 1) . '-' : ''; return $prefix . $dependency . '-file'; }