/** * 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; } }
/** * Validates the tag. * * @param string $tag * @param AssetTypeInterface $assetType * @param VersionParser|null $parser * * @return false|string */ public static function validateTag($tag, AssetTypeInterface $assetType, VersionParser $parser = null) { if (in_array($tag, array('master', 'trunk', 'default'))) { return false; } if (null === $parser) { $parser = new VersionParser(); } try { $tag = $assetType->getVersionConverter()->convertVersion($tag); $tag = $parser->normalize($tag); } catch (\Exception $e) { $tag = false; } return $tag; }
/** * Check if the version must be skipped. * * @param AssetTypeInterface $assetType The asset type * @param string $name The composer package name * @param string $version The version * * @return bool */ public function skip(AssetTypeInterface $assetType, $name, $version) { if (!isset($this->requires[$name])) { return false; } /* @var Link $require */ $require = $this->requires[$name]; try { $cVersion = $assetType->getVersionConverter()->convertVersion($version); $normalizedVersion = $this->versionParser->normalize($cVersion); return !$this->satisfy($require, $normalizedVersion); } catch (\Exception $ex) { return true; } }
/** * Check if the version must be skipped. * * @param AssetTypeInterface $assetType The asset type * @param string $name The composer package name * @param string $version The version * * @return bool */ public function skip(AssetTypeInterface $assetType, $name, $version) { try { $cVersion = $assetType->getVersionConverter()->convertVersion($version); $normalizedVersion = $this->versionParser->normalize($cVersion); } catch (\Exception $ex) { return true; } if (false !== $this->skipByPattern() && $this->forceSkipVersion($normalizedVersion)) { return true; } return $this->doSkip($name, $normalizedVersion); }
public function testConverter() { $this->assertInstanceOf('Fxp\\Composer\\AssetPlugin\\Converter\\PackageConverterInterface', $this->type->getPackageConverter()); $this->assertInstanceOf('Fxp\\Composer\\AssetPlugin\\Converter\\VersionConverterInterface', $this->type->getVersionConverter()); }
/** * Get the version of url file dependency. * * @param AssetTypeInterface $assetType The asset type * @param string $url The url * @param string $version The version * * @return string The version */ protected static function getUrlFileDependencyVersion(AssetTypeInterface $assetType, $url, $version) { if ('#' !== $version) { return substr($version, 1); } if (preg_match('/(\\d+)(\\.\\d+)(\\.\\d+)?(\\.\\d+)?/', $url, $match)) { return $assetType->getVersionConverter()->convertVersion($match[0]); } return '0.0.0.0'; }