protected function updatePackage(Package &$model, KeekoPackageSchema $pkg) { $packageName = $pkg->getPackage()->getFullName(); $result = PackageQuery::create()->filterByName($packageName)->count(); $info = $this->service->getPackageManager()->getComposerPackage($packageName); if ($result == 0) { $model->setTitle($pkg->getTitle()); $model->setDescription($info->getDescription()); $model->setName($packageName); $model->setInstalledVersion($info->getPrettyVersion()); $model->save(); } $this->updateExtensions($model, $pkg); }
/** * Deletes all rows from the kk_application table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). */ public function doDeleteAll(ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(ApplicationTableMap::DATABASE_NAME); } // use transaction because $criteria could contain info // for more than one table or we could emulating ON DELETE CASCADE, etc. return $con->transaction(function () use($con) { $affectedRows = 0; // initialize var to track total num of affected rows $affectedRows += parent::doDeleteAll($con); // Because this db requires some delete cascade/set null emulation, we have to // clear the cached instance *after* the emulation has happened (since // instances get re-added by the select statement contained therein). ApplicationTableMap::clearInstancePool(); ApplicationTableMap::clearRelatedInstancePool(); return $affectedRows; }); }
/** * Performs an INSERT on the database, given a Package or Criteria object. * * @param mixed $criteria Criteria or Package object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(PackageTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from Package object } if ($criteria->containsKey(PackageTableMap::COL_ID) && $criteria->keyContainsValue(PackageTableMap::COL_ID)) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . PackageTableMap::COL_ID . ')'); } // Set the correct dbName $query = PackageQuery::create()->mergeWith($criteria); // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) return $con->transaction(function () use($con, $query) { return $query->doInsert($con); }); }
/** * Builds a Criteria object containing the primary key for this object. * * Unlike buildCriteria() this method includes the primary key values regardless * of whether or not they have been modified. * * @throws LogicException if no primary key is defined * * @return Criteria The Criteria object containing value(s) for primary key(s). */ public function buildPkeyCriteria() { $criteria = ChildPackageQuery::create(); $criteria->add(PackageTableMap::COL_ID, $this->id); return $criteria; }
/** * Get the associated ChildPackage object * * @param ConnectionInterface $con Optional Connection object. * @return ChildPackage The associated ChildPackage object. * @throws PropelException */ public function getPackage(ConnectionInterface $con = null) { if ($this->aPackage === null && $this->package_id !== null) { $this->aPackage = ChildPackageQuery::create()->findPk($this->package_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aPackage->addExtensions($this); */ } return $this->aPackage; }
/** * Returns a new ChildPackageQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return ChildPackageQuery */ public static function create($modelAlias = null, Criteria $criteria = null) { if ($criteria instanceof ChildPackageQuery) { return $criteria; } $query = new ChildPackageQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * Get or Create the parent ChildPackage object of the current object * * @return ChildPackage The parent object */ public function getParentOrCreate($con = null) { if ($this->isNew()) { if ($this->isPrimaryKeyNull()) { $parent = new ChildPackage(); $parent->setDescendantClass('keeko\\core\\model\\Application'); return $parent; } else { $parent = \keeko\core\model\PackageQuery::create()->findPk($this->getPrimaryKey(), $con); if (null === $parent || null !== $parent->getDescendantClass()) { $parent = new ChildPackage(); $parent->setPrimaryKey($this->getPrimaryKey()); $parent->setDescendantClass('keeko\\core\\model\\Application'); } return $parent; } } else { return ChildPackageQuery::create()->findPk($this->getPrimaryKey(), $con); } }