本文整理汇总了PHP中GitRepository::changeAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP GitRepository::changeAccess方法的具体用法?PHP GitRepository::changeAccess怎么用?PHP GitRepository::changeAccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GitRepository
的用法示例。
在下文中一共展示了GitRepository::changeAccess方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process()
{
$parameters = $this->getParametersAsArray();
//repo id
$repositoryId = '';
if (!empty($parameters[0])) {
$repositoryId = $parameters[0];
} else {
$this->error('Missing argument repository id');
return false;
}
//repo access
$repositoryAccess = '';
if (!empty($parameters[1])) {
$repositoryAccess = $parameters[1];
} else {
$this->error('Missing argument repository access');
return false;
}
//save
$repository = new GitRepository();
$repository->setId($repositoryId);
try {
$repository->load();
$repository->setAccess($repositoryAccess);
$repository->changeAccess();
} catch (GitDaoException $e) {
$this->error($e->getMessage());
return false;
}
$this->done();
}
示例2: changeProjectRepositoriesAccess
/**
* Internal method called by SystemEvent_PROJECT_IS_PRIVATE
* @param <type> $projectId
* @param <type> $isPublic
* @return <type>
*/
public static function changeProjectRepositoriesAccess($projectId, $isPrivate)
{
//if the project is private, then no changes may be applied to repositories,
//in other words only if project is set to private, its repositories have to be set to private
if (empty($isPrivate)) {
return;
}
$dao = new GitDao();
$repositories = $dao->getProjectRepositoryList($projectId);
if (empty($repositories)) {
return false;
}
foreach ($repositories as $repoId => $repoData) {
$r = new GitRepository();
$r->setId($repoId);
if (!$r->exists()) {
continue;
}
$newAccess = !empty($isPrivate) ? GitRepository::PRIVATE_ACCESS : GitRepository::PUBLIC_ACCESS;
if ($r->getAccess() == $newAccess) {
continue;
}
$r->setAccess($newAccess);
$r->changeAccess();
unset($r);
}
}