setVersionsHistory() public méthode

Set bundle versions history
public setVersionsHistory ( array $versions )
$versions array
 /**
  * @Given /^the site has following bundles:$/
  */
 public function theSiteHasFollowingBundles(TableNode $table)
 {
     $entityManager = $this->getEntityManager();
     $this->bundles = array();
     foreach ($table->getHash() as $row) {
         if (isset($this->developers[$row['username']])) {
             $owner = $this->developers[$row['username']];
         } elseif (isset($this->organizations[$row['username']])) {
             $owner = $this->organizations[$row['username']];
         } else {
             continue;
         }
         $bundle = new Entity\Bundle();
         $bundle->fromArray(array('name' => $row['name'], 'owner' => $owner, 'ownerName' => $owner->getName(), 'description' => $row['description'], 'readme' => isset($row['readme']) ? $row['readme'] : '', 'state' => isset($row['state']) ? $row['state'] : Entity\Bundle::STATE_UNKNOWN));
         if (isset($row['license'])) {
             $bundle->setLicenseType($row['license']);
         }
         if (isset($row['createdAt'])) {
             $bundle->setCreatedAt(new \DateTime($row['createdAt']));
         }
         if (isset($row['lastCommitAt'])) {
             $bundle->setLastCommitAt(new \DateTime($row['lastCommitAt']));
         }
         $bundle->setScore($row['score']);
         $versionsHistory['dependencies']['dev-master'] = array('name' => 'friendsofsymfony/user-bundle', 'extra' => array('branch-alias' => array('dev-master' => '2.0.x-dev')), 'require' => array('php' => '>=5.3.2'), 'require-dev' => '', 'suggest' => '');
         $bundle->setVersionsHistory($versionsHistory);
         $this->setPrivateProperty($bundle, "trend1", $row['trend1']);
         if (isset($row['recommendedBy'])) {
             $ownerNames = explode(',', $row['recommendedBy']);
             foreach ($ownerNames as $ownerName) {
                 $owner = $this->developers[trim($ownerName)];
                 $bundle->addRecommender($owner);
                 $owner->addRecommendedBundle($bundle);
                 $entityManager->persist($owner);
             }
         }
         $entityManager->persist($bundle);
         $this->bundles[$bundle->getName()] = $bundle;
     }
     $entityManager->flush();
 }
Exemple #2
0
 public function updateVersionsHistory(Bundle $bundle)
 {
     // no composer file
     if (null === ($composerName = $bundle->getComposerName())) {
         return false;
     }
     // query packagist json
     $packagistArray = $this->github->getHttpClient()->get($composerName, array(), array('url' => 'http://packagist.org/packages/:path.json'));
     // if json not encoded
     if (!is_array($packagistArray) || !isset($packagistArray['package'])) {
         return false;
     }
     $versionsHistory = array();
     $versionsArray = $packagistArray['package']['versions'];
     foreach ($versionsArray as $version => $value) {
         // Skip `dev` packages, add only `dev-master`
         if (0 === strpos($version, 'dev-') && 'dev-master' != $version) {
             continue;
         }
         foreach (array('symfony/framework-bundle', 'symfony/symfony') as $requirement) {
             if (isset($value['require'][$requirement])) {
                 $versionsHistory['symfony'][$version] = $value['require'][$requirement];
                 // array('master' => '>=2.0,<2.2-dev')
             }
         }
         // store all bundle dependencies
         $versionsHistory['dependencies'][$version] = array('name' => $value['name'], 'extra' => isset($value['extra']) ? $value['require-dev'] : '', 'require' => $value['require'], 'require-dev' => isset($value['require-dev']) ? $value['require-dev'] : '', 'suggest' => isset($value['suggest']) ? $value['suggest'] : '');
     }
     if (!empty($versionsHistory)) {
         $bundle->setVersionsHistory($versionsHistory);
     }
     return true;
 }