本文整理汇总了PHP中Branch::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP Branch::setName方法的具体用法?PHP Branch::setName怎么用?PHP Branch::setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Branch
的用法示例。
在下文中一共展示了Branch::setName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* @param sfWebRequest $request
* @return void
*/
public function execute($request)
{
$projectId = $request->getParameter('project_id');
$baseBranchName = $request->getParameter('base_branch');
$branchName = $request->getParameter('branch');
$commit = (string) $request->getParameter('commit');
// Last commit
$result = array();
file_put_contents(sprintf("%s/api.log", sfConfig::get('sf_log_dir')), sprintf("%s [%s] set review = projectId : %s - baseBranchName : %s - branchName : %s - commit : %s\n", date('d/m/Y H:i:s'), $_SERVER['REMOTE_ADDR'], $projectId, $baseBranchName, $branchName, $commit), FILE_APPEND);
$repository = RepositoryQuery::create()->filterById($projectId)->findOne();
if ($repository) {
$branch = BranchQuery::create()->filterByRepositoryId($repository->getId())->filterByName($branchName)->findOne();
if (!$branch) {
$branch = new Branch();
$branch->setName($branchName)->setRepositoryId($repository->getId())->setBaseBranchName($baseBranchName)->save();
}
if ($branch->getBaseBranchName() != $baseBranchName) {
$branch->setBaseBranchName($baseBranchName)->save();
}
if (($nbFiles = BranchPeer::synchronize($this->gitCommand, $repository, $branch)) != 0) {
$result['message'] = sprintf("Your branch '%s' has too many files : %s (max : %s)", $branch->__toString(), $nbFiles, sfConfig::get('app_max_number_of_files_to_review', 4096));
$this->getResponse()->setStatusCode('500');
} elseif (!$branch->isDeleted()) {
if (strlen($commit) === 40) {
if (!$this->gitCommand->commitIsInHistory($repository->getGitDir(), $branch->getCommitStatusChanged(), $commit)) {
$result['message'] = sprintf("Review has been %sengaged [old status : %s]", $branch->getReviewRequest() ? 're' : '', BranchPeer::getLabelStatus($branch->getStatus()));
$branch->setReviewRequest(1)->setStatus(BranchPeer::A_TRAITER)->setIsBlacklisted(0)->save();
$this->getResponse()->setStatusCode('201');
$this->dispatcher->notify(new sfEvent($this, 'notification.review-request', array('project-id' => $branch->getRepositoryId(), 'object' => $branch)));
} else {
$result['message'] = sprintf("Commit already used : '%s'", $commit);
$this->getResponse()->setStatusCode('200');
}
} else {
$result['message'] = sprintf("No valid commit '%s'", $commit);
$this->getResponse()->setStatusCode('422');
}
} else {
$result['message'] = sprintf("Unknown branch '%s' in project '%s'", $branchName, $repository->getName());
$this->getResponse()->setStatusCode('404');
}
} else {
$result['message'] = sprintf("No valid project '%s'", $projectId);
$this->getResponse()->setStatusCode('400');
}
$this->getResponse()->setContentType('application/json');
return $this->renderText(json_encode($result));
}
示例2: executeBulkupload
public function executeBulkupload()
{
if ($this->getRequest()->getFileName('csvfile')) {
$fileName = md5($this->getRequest()->getFileName('csvfile') . time() . rand(0, 99999));
$ext = $this->getRequest()->getFileExtension('csvfile');
$this->getRequest()->moveFile('csvfile', sfConfig::get('sf_upload_dir') . "//csvfiles//" . $fileName . ".csv");
$fullname = $fileName . ".csv";
//$fullpath = '/uploads/csvfiles/'.$fullname;
$fp = sfConfig::get('sf_upload_dir') . "//csvfiles//" . $fileName . ".csv";
$reader = new sfCsvReader($fp, ',', '"');
$reader->open();
$i = 1;
$exist;
$ignore;
$log;
$ignoreflag = 0;
$success = 0;
while ($data = $reader->read()) {
$name[] = array();
$name = explode(' ', $data[0]);
$roll = $data[1];
$enrol = $data[2];
$branch = $data[3];
$degree = $data[4];
$year = $data[5];
$c = new Criteria();
$c->add(UserPeer::ENROLMENT, $enrol);
$user = UserPeer::doSelectOne($c);
if (!$user) {
$c = new Criteria();
$c->add(BranchPeer::CODE, $branch);
$br = BranchPeer::doSelectOne($c);
if (!$br) {
$br = new Branch();
$br->setName($branch);
$br->setCode($branch);
$br->save();
}
$c = new Criteria();
$c->add(DegreePeer::NAME, $degree);
$dg = DegreePeer::doSelectOne($c);
if (!$dg) {
$dg = new Degree();
$dg->setName($degree);
$dg->save();
}
$user = new User();
if ($roll) {
$user->setRoll($roll);
$user->setRollflag(sfConfig::get('app_defaultprivacy_roll'));
}
if ($enrol) {
$user->setEnrolment($enrol);
$user->setEnrolflag(sfConfig::get('app_defaultprivacy_enrol'));
} else {
$ignoreflag = 1;
}
if ($year) {
$user->setGraduationyear($year);
$user->setGraduationyearflag(sfConfig::get('app_defaultprivacy_year'));
}
$user->setBranchId($br->getId());
$user->setBranchflag(sfConfig::get('app_defaultprivacy_branch'));
$user->setDegreeId($dg->getId());
$user->setDegreeflag(sfConfig::get('app_defaultprivacy_degree'));
$user->setIslocked(sfConfig::get('app_islocked_unclaimed'));
$user->setUsertype(sfConfig::get('app_usertypecode_Alumni'));
$lastname = '';
$personal = new Personal();
$name[0] = str_replace('.', '', $name[0]);
$personal->setFirstname($name[0]);
if ($name[3]) {
$name[1] = str_replace('.', '', $name[1]);
$name[2] = str_replace('.', '', $name[2]);
$name[3] = str_replace('.', '', $name[3]);
$midname = $name[1] . " " . $name[2];
$personal->setMiddlename($midname);
$personal->setLastname($name[3]);
$lastname = $name[3];
} elseif ($name[2]) {
$name[1] = str_replace('.', '', $name[1]);
$name[2] = str_replace('.', '', $name[2]);
$personal->setMiddlename($name[1]);
$personal->setLastname($name[2]);
$lastname = $name[2];
} elseif ($name[1]) {
$name[1] = str_replace('.', '', $name[1]);
$personal->setLastname($name[1]);
$lastname = $name[1];
}
$uname_suffix = $branch . substr($year, -2);
if ($lastname) {
$username = $name[0] . '.' . $lastname . '@';
} else {
$username = $name[0] . '@';
}
$temp = 1;
$tempusername = $username;
while ($this->uniqueuser($tempusername . $uname_suffix)) {
$tempusername = $username . $temp;
//.........这里部分代码省略.........