public function getPackage()
 {
     $package = parent::getPackage();
     if ($package === null) {
         $package = $this->pdo->findPackageById($this->getPackageId());
         $this->setPackage($package);
     }
     return $package;
 }
Exemplo n.º 2
0
 public function persistVersion(Version $version)
 {
     $data = array($version->getPackage()->getId(), $version->getVersion(), $version->getReferenceHash(), $version->getReferenceName(), $version->getLicense(), $version->getCreatedAt()->format('Y-m-d H:i:s'), $version->getUpdatedAt()->format('Y-m-d H:i:s'));
     if ($version->getId()) {
         $data[] = $version->getId();
         $sql = "UPDATE " . $this->getTablePrefix() . "version\n                    SET\n                        package_id = ?,\n                        version = ?,\n                        reference_hash = ?,\n                        reference_name = ?,\n                        license = ?,\n                        created_at = ?,\n                        updated_at = ?\n                    WHERE\n                        id = ?";
         $stmt = $this->pdo->prepare($sql);
         $stmt->execute($data);
     } else {
         $sql = "INSERT INTO " . $this->getTablePrefix() . "version\n                    (package_id, version, reference_hash, reference_name, license, created_at, updated_at)\n                    VALUES\n                    (?, ?, ?, ?, ?, ?, ?)";
         $stmt = $this->pdo->prepare($sql);
         $stmt->execute($data);
         $version->setId((int) $this->pdo->lastInsertId());
     }
     $this->persistDependencies($version, $version->getDependencies());
 }