示例#1
0
 /**
  * @param string $packageName
  * @return string
  */
 public function getVersion($packageName = OroPlatformBundle::PACKAGE_NAME)
 {
     // Get package version from local cache if any
     if (isset($this->packageVersions[$packageName])) {
         return $this->packageVersions[$packageName];
     }
     // Try to get package version from persistent cache
     if ($this->cache && $this->cache->contains($packageName)) {
         $version = $this->cache->fetch($packageName);
     } else {
         // Get package version from composer repository
         $packages = $this->factory->getLocalRepository()->findPackages($packageName);
         if ($package = current($packages)) {
             /** @var PackageInterface $package */
             $version = $package->getPrettyVersion();
         } else {
             $version = self::UNDEFINED_VERSION;
         }
         //Save package version to persistent cache
         if ($this->cache) {
             $this->cache->save($packageName, $version);
         }
     }
     // Save package version to local cache
     $this->packageVersions[$packageName] = $version;
     return $version;
 }
 public function testGetRepository()
 {
     $repository = $this->manager->getLocalRepository();
     $this->assertInstanceOf('Composer\\Repository\\InstalledFilesystemRepository', $repository);
     $packages = $repository->getCanonicalPackages();
     $this->assertCount(2, $repository->getCanonicalPackages());
     $this->assertEquals(OroPlatformBundle::PACKAGE_NAME, $packages[0]->getName());
     $this->assertEquals('oro/crm', $packages[1]->getName());
 }