本文整理汇总了PHP中GitRepository::load方法的典型用法代码示例。如果您正苦于以下问题:PHP GitRepository::load方法的具体用法?PHP GitRepository::load怎么用?PHP GitRepository::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GitRepository
的用法示例。
在下文中一共展示了GitRepository::load方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getRepository
/**
* Wrapper for GitRepository for unit testing purpose
*
* @param array $row data of the repository to instantiate
*
* @return GitRepository
*/
protected function getRepository($row)
{
$r = new GitRepository();
$r->setId($row[GitDao::REPOSITORY_ID]);
$r->load();
return $r;
}
示例3: GitRepository
function permission_user_allowed_to_change($params)
{
if (!$params['allowed']) {
if (!$this->_cached_permission_user_allowed_to_change) {
if (in_array($params['permission_type'], array('PLUGIN_GIT_READ', 'PLUGIN_GIT_WRITE', 'PLUGIN_GIT_WPLUS'))) {
require_once 'GitRepository.class.php';
$repository = new GitRepository();
$repository->setId($params['object_id']);
try {
$repository->load();
//Only project admin can update perms of project repositories
//Only repo owner can update perms of personal repositories
$user = UserManager::instance()->getCurrentUser();
$this->_cached_permission_user_allowed_to_change = $repository->belongsTo($user) || $user->isMember($repository->getProjectId(), 'A');
} catch (Exception $e) {
// do nothing
}
}
}
$params['allowed'] = $this->_cached_permission_user_allowed_to_change;
}
}
示例4: _listOfMails
/**
* LIST OF MAILS TO NOTIFY
*/
protected function _listOfMails()
{
$r = new GitRepository();
$r->setId($this->repoId);
$r->load();
$mails = $r->getNotifiedMails();
?>
<h3><?php
echo $this->getText('notified_mails_title');
?>
</h3>
<?php
if (!empty($mails)) {
?>
<form id="add_user_form" action="/plugins/git/" method="POST">
<input type="hidden" id="action" name="action" value="remove_mail" />
<input type="hidden" id="group_id" name="group_id" value="<?php
echo $this->groupId;
?>
" />
<input type="hidden" id="repo_id" name="repo_id" value="<?php
echo $this->repoId;
?>
" />
<table>
<?php
$i = 0;
foreach ($mails as $mail) {
echo '<tr class="' . html_get_alt_row_color(++$i) . '">';
echo '<td>' . $mail . '</td>';
echo '<td>';
echo '<input type="checkbox" name="mail[]" value="' . $this->HTMLPurifier->purify($mail) . '" />';
echo '</a>';
echo '</td>';
echo '</tr>';
}
?>
</table>
<input type="submit" value="<?php
echo $GLOBALS['Language']->getText('global', 'btn_delete');
?>
" />
</form>
<?php
} else {
?>
<h4><?php
echo $this->getText('add_mail_existing');
?>
</h4>
<?php
}
}
示例5: save
/**
* This method allows one to save any repository attribues changes from the web interface.
* @param <type> $repoId
* @param <type> $repoAccess
* @param <type> $repoDescription
* @return <type>
*/
public function save($projectId, $repoId, $repoAccess, $repoDescription)
{
$c = $this->getController();
if (empty($repoId)) {
$c->addError($this->getText('actions_params_error'));
$c->redirect('/plugins/git/?action=index&group_id=' . $projectId);
return false;
}
if (empty($repoAccess) || empty($repoDescription)) {
$c->addError($this->getText('actions_params_error'));
$c->redirect('/plugins/git/index.php/' . $projectId . '/view/' . $repoId . '/');
return false;
}
$repository = new GitRepository();
$repository->setId($repoId);
try {
$repository->load();
if (!empty($repoAccess)) {
if ($repository->getBackend() instanceof Git_Backend_Gitolite) {
$repository->getBackend()->savePermissions($repository, $repoAccess);
} else {
if ($repository->getAccess() != $repoAccess) {
$this->systemEventManager->createEvent('GIT_REPO_ACCESS', $repoId . SystemEvent::PARAMETER_SEPARATOR . $repoAccess, SystemEvent::PRIORITY_HIGH);
$c->addInfo($this->getText('actions_repo_access'));
}
}
}
if (strlen($repoDescription) > 1024) {
$c->addError($this->getText('actions_long_description'));
} elseif (!empty($repoDescription)) {
$repository->setDescription($repoDescription);
}
} catch (GitDaoException $e) {
$c->addError($this->getText('actions_repo_not_found'));
$c->redirect('/plugins/git/?group_id=' . $projectId);
return false;
} catch (GitRepositoryException $e1) {
die('GitRepositoryException');
$c->addError($e1->getMessage());
return false;
}
try {
$repository->save();
} catch (GitDaoException $e) {
$c->addError($e->getMessage());
$c->redirect('/plugins/git/index.php/' . $projectId . '/view/' . $repoId . '/');
return false;
}
$c->addInfo($this->getText('actions_save_repo_process'));
$c->redirect('/plugins/git/index.php/' . $projectId . '/view/' . $repoId . '/');
return;
}
示例6: GitRepository
function permission_user_allowed_to_change($params)
{
if (!$params['allowed']) {
$user = $this->getCurrentUser();
$project = $this->getProjectManager()->getProject($params['group_id']);
if ($this->getGitPermissionsManager()->userIsGitAdmin($user, $project)) {
$this->_cached_permission_user_allowed_to_change = true;
}
if (!$this->_cached_permission_user_allowed_to_change) {
if (in_array($params['permission_type'], array('PLUGIN_GIT_READ', 'PLUGIN_GIT_WRITE', 'PLUGIN_GIT_WPLUS'))) {
$repository = new GitRepository();
$repository->setId($params['object_id']);
try {
$repository->load();
//Only project admin can update perms of project repositories
//Only repo owner can update perms of personal repositories
$this->_cached_permission_user_allowed_to_change = $repository->belongsTo($user) || $this->getPermissionsManager()->userIsGitAdmin($user, $project);
} catch (Exception $e) {
// do nothing
}
}
}
$params['allowed'] = $this->_cached_permission_user_allowed_to_change;
}
}
示例7: process
public function process()
{
$parameters = $this->getParametersAsArray();
//print_r($parameters);
$project = null;
if (!empty($parameters[0])) {
$project = $this->getProject($parameters[0]);
} else {
$this->error('Missing argument project id');
return false;
}
$repositoryName = '';
if (!empty($parameters[1])) {
$repositoryName = $parameters[1];
} else {
$this->error('Missing argument repository name');
return false;
}
$parentId = '';
if (!empty($parameters[2])) {
$parentId = $parameters[2];
} else {
$this->error('Missing argument parent id');
return false;
}
$userId = 0;
if (!empty($parameters[3])) {
$userId = $parameters[3];
} else {
$this->error('Missing argument user id');
return false;
}
try {
$repository = new GitRepository();
$repository->setProject($project);
$repository->setId($parentId);
//load before setting creator
$repository->load();
$user = null;
if (!empty($userId)) {
$user = UserManager::instance()->getUserById($userId);
}
if (!empty($user)) {
$repository->setCreator($user);
}
$repository->forkShell($repositoryName);
$this->done();
} catch (GitDaoException $e1) {
$this->error($e1->getMessage());
return false;
} catch (GitDriverException $e2) {
$this->error($e2->getMessage());
return false;
} catch (GitBackendException $e3) {
$this->error($e3->getMessage());
return false;
} catch (Exception $e4) {
$this->error($e4->getMessage());
return false;
}
}
示例8: loadRepositoryFromId
/**
* Load a repository from its id. Mainly used as a wrapper for tests
*
* @param $repositoryId Id of the repository
*
* @return GitRepository
*/
function loadRepositoryFromId($repositoryId)
{
$repository = new GitRepository();
$repository->setId($repositoryId);
$repository->load();
return $repository;
}