/** * @param sfWebRequest $request * @return void */ public function execute($request) { $repository = RepositoryPeer::retrieveByPK($request->getParameter('repository')); $this->forward404Unless($repository, "Repository Not Found"); $branches = BranchQuery::create()->filterByRepositoryId($repository->getId())->filterByIsBlacklisted(0)->find(); foreach ($branches as $branch) { BranchPeer::synchronize($this->gitCommand, $repository, $branch, true); } $this->redirect('default/branchList?repository=' . $repository->getId()); }
/** * @param sfWebRequest $request * @return void */ public function execute($request) { $this->file = FilePeer::retrieveByPK($request->getParameter('file')); $this->forward404Unless($this->file, "File not found"); $this->branch = BranchPeer::retrieveByPK($this->file->getBranchId()); $this->forward404Unless($this->branch, "Branch not found"); $this->repository = RepositoryPeer::retrieveByPK($this->branch->getRepositoryId()); $this->forward404Unless($this->repository, "Repository not found"); $this->fileContent = $this->gitCommand->getShowFile($this->repository->getGitDir(), $this->file->getLastChangeCommit(), $this->file->getFilename()); $this->fileExtension = pathinfo($this->file->getFilename(), PATHINFO_EXTENSION); }
/** * @param sfWebRequest $request * @return void */ public function execute($request) { $this->branch = null; if ($request->hasParameter('name') && $request->hasParameter('repository')) { $repository = RepositoryQuery::create()->filterByName($request->getParameter('repository'))->findOne(); $this->forward404Unless($repository, "Repository not found"); $this->branch = BranchQuery::create()->filterByName($request->getParameter('name'))->filterByRepository($repository)->findOne(); // Dirty hack to make the breadcrumb work /!\ if ($this->branch) { $this->redirect('default/fileList?branch=' . $this->branch->getId()); } } elseif ($request->hasParameter('branch')) { $this->branch = BranchPeer::retrieveByPK($request->getParameter('branch')); } $this->forward404Unless($this->branch, "Branch not found"); $this->getResponse()->setTitle($this->branch->getName()); $this->repository = RepositoryPeer::retrieveByPK($this->branch->getRepositoryId()); $this->forward404Unless($this->repository, "Repository not found"); $files = FileQuery::create()->filterByBranchId($this->branch->getId())->find(); $this->files = array(); foreach ($files as $file) { $fileCommentsCount = CommentQuery::create()->filterByFileId($file->getId())->filterByType(CommentPeer::TYPE_FILE)->count(); $fileCommentsCountNotChecked = CommentQuery::create()->filterByFileId($file->getId())->filterByType(CommentPeer::TYPE_FILE)->filterByCheckUserId(null)->count(); $lineCommentsCount = CommentQuery::create()->filterByFileId($file->getId())->filterByCommit($file->getLastChangeCommit())->filterByType(CommentPeer::TYPE_LINE)->count(); $lineCommentsCountNotChecked = CommentQuery::create()->filterByFileId($file->getId())->filterByCommit($file->getLastChangeCommit())->filterByType(CommentPeer::TYPE_LINE)->filterByCheckUserId(null)->count(); $lastCommentId = 0; if ($fileCommentsCount || $lineCommentsCount) { $lastComment = CommentQuery::create()->filterByFileId($file->getId())->filterByCommit($file->getLastChangeCommit())->_or()->filterByType(CommentPeer::TYPE_FILE)->orderById(Criteria::DESC)->findOne(); if ($lastComment) { $lastCommentId = $lastComment->getId(); } } $this->files[] = array_merge($file->toArray(), array('NbFileComments' => $fileCommentsCount + $lineCommentsCount, 'NbFileCommentsNotChecked' => $fileCommentsCountNotChecked + $lineCommentsCountNotChecked, 'LastCommentId' => $lastCommentId)); } usort($this->files, array('self', 'sortPath')); $this->statusActions = StatusActionPeer::getStatusActionsForBoard(null, $this->repository->getId(), $this->branch->getId()); $this->commentBoards = CommentPeer::getCommentsForBoard(null, $this->repository->getId(), $this->branch->getId()); }
/** * @param sfWebRequest $request * @return void */ public function execute($request) { $this->file = FilePeer::retrieveByPK($request->getParameter('file')); $this->forward404Unless($this->file, "File not found"); $this->getResponse()->setTitle(basename($this->file->getFilename())); $this->previousFileId = FileQuery::create()->select('Id')->filterByBranchId($this->file->getBranchId())->filterByFilename($this->file->getFilename(), Criteria::LESS_THAN)->filterByIsBinary(false)->orderByFilename(Criteria::DESC)->findOne(); $this->nextFileId = FileQuery::create()->select('Id')->filterByBranchId($this->file->getBranchId())->filterByFilename($this->file->getFilename(), Criteria::GREATER_THAN)->filterByIsBinary(false)->orderByFilename(Criteria::ASC)->findOne(); $this->branch = BranchPeer::retrieveByPK($this->file->getBranchId()); $this->forward404Unless($this->branch, "Branch not found"); $this->repository = RepositoryPeer::retrieveByPK($this->branch->getRepositoryId()); $this->forward404Unless($this->repository, "Repository not found"); $options = array(); if ($request->getParameter('s', false)) { $options['ignore-all-space'] = true; } $this->fileContentLines = $this->gitCommand->getShowFileFromBranch($this->repository->getGitDir(), $this->branch->getCommitReference(), $this->file->getLastChangeCommit(), $this->file->getFilename(), $options); $fileLineCommentsModel = CommentQuery::create()->filterByFileId($this->file->getId())->filterByCommit($this->file->getLastChangeCommit())->filterByType(CommentPeer::TYPE_LINE)->find(); $this->userId = $this->getUser()->getId(); $this->fileLineComments = array(); foreach ($fileLineCommentsModel as $fileLineCommentModel) { $this->fileLineComments[$fileLineCommentModel->getPosition()][] = $fileLineCommentModel; } }
/** * Selects a collection of StatusAction objects pre-filled with all related objects except File. * * @param Criteria $criteria * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of StatusAction objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptFile(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden // $criteria->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(self::DATABASE_NAME); } StatusActionPeer::addSelectColumns($criteria); $startcol2 = StatusActionPeer::NUM_HYDRATE_COLUMNS; sfGuardUserPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + sfGuardUserPeer::NUM_HYDRATE_COLUMNS; RepositoryPeer::addSelectColumns($criteria); $startcol4 = $startcol3 + RepositoryPeer::NUM_HYDRATE_COLUMNS; BranchPeer::addSelectColumns($criteria); $startcol5 = $startcol4 + BranchPeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(StatusActionPeer::USER_ID, sfGuardUserPeer::ID, $join_behavior); $criteria->addJoin(StatusActionPeer::REPOSITORY_ID, RepositoryPeer::ID, $join_behavior); $criteria->addJoin(StatusActionPeer::BRANCH_ID, BranchPeer::ID, $join_behavior); // symfony_behaviors behavior foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) { call_user_func($sf_hook, 'BaseStatusActionPeer', $criteria, $con); } $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = StatusActionPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = StatusActionPeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $cls = StatusActionPeer::getOMClass(false); $obj1 = new $cls(); $obj1->hydrate($row); StatusActionPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined sfGuardUser rows $key2 = sfGuardUserPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = sfGuardUserPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = sfGuardUserPeer::getOMClass(false); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); sfGuardUserPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (StatusAction) to the collection in $obj2 (sfGuardUser) $obj2->addStatusAction($obj1); } // if joined row is not null // Add objects for joined Repository rows $key3 = RepositoryPeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = RepositoryPeer::getInstanceFromPool($key3); if (!$obj3) { $cls = RepositoryPeer::getOMClass(false); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); RepositoryPeer::addInstanceToPool($obj3, $key3); } // if $obj3 already loaded // Add the $obj1 (StatusAction) to the collection in $obj3 (Repository) $obj3->addStatusAction($obj1); } // if joined row is not null // Add objects for joined Branch rows $key4 = BranchPeer::getPrimaryKeyHashFromRow($row, $startcol4); if ($key4 !== null) { $obj4 = BranchPeer::getInstanceFromPool($key4); if (!$obj4) { $cls = BranchPeer::getOMClass(false); $obj4 = new $cls(); $obj4->hydrate($row, $startcol4); BranchPeer::addInstanceToPool($obj4, $key4); } // if $obj4 already loaded // Add the $obj1 (StatusAction) to the collection in $obj4 (Branch) $obj4->addStatusAction($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. * * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * * @return Repository A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { $sql = 'SELECT `ID`, `NAME`, `VALUE`, `REMOTE` FROM `repository` WHERE `ID` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); } $obj = null; if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $obj = new Repository(); $obj->hydrate($row); RepositoryPeer::addInstanceToPool($obj, (string) $row[0]); } $stmt->closeCursor(); return $obj; }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(RepositoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(RepositoryPeer::DATABASE_NAME); $criteria->add(RepositoryPeer::ID, $pks, Criteria::IN); $objs = RepositoryPeer::doSelect($criteria, $con); } return $objs; }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's phpname (e.g. 'AuthorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = RepositoryPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setName($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setValue($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setRemote($arr[$keys[3]]); } }