本文整理汇总了PHP中GitRepository::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP GitRepository::setId方法的具体用法?PHP GitRepository::setId怎么用?PHP GitRepository::setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GitRepository
的用法示例。
在下文中一共展示了GitRepository::setId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetMailHookConfig
public function testGetMailHookConfig()
{
$prj = new MockProject($this);
$prj->setReturnValue('getUnixName', 'project1');
$prj->setReturnValue('getId', 101);
// ShowRev
$repo = new GitRepository();
$repo->setId(5);
$repo->setProject($prj);
$repo->setName('test_default');
$this->assertIdentical(file_get_contents($this->_fixDir . '/gitolite-mail-config/mailhook-rev.txt'), $this->project_serializer->fetchMailHookConfig($prj, $repo));
// ShowRev + Mail
$repo = new GitRepository();
$repo->setId(5);
$repo->setProject($prj);
$repo->setName('test_default');
$repo->setNotifiedMails(array('john.doe@enalean.com', 'mme.michue@enalean.com'));
$this->assertIdentical(file_get_contents($this->_fixDir . '/gitolite-mail-config/mailhook-rev-mail.txt'), $this->project_serializer->fetchMailHookConfig($prj, $repo));
// ShowRev + Mailprefix
$repo = new GitRepository();
$repo->setId(5);
$repo->setProject($prj);
$repo->setName('test_default');
$repo->setNotifiedMails(array('john.doe@enalean.com', 'mme.michue@enalean.com'));
$repo->setMailPrefix('[KOIN] ');
$this->assertIdentical(file_get_contents($this->_fixDir . '/gitolite-mail-config/mailhook-rev-mail-prefix.txt'), $this->project_serializer->fetchMailHookConfig($prj, $repo));
// ShowRev + Mailprefix
$repo = new GitRepository();
$repo->setId(5);
$repo->setProject($prj);
$repo->setName('test_default');
$repo->setNotifiedMails(array('john.doe@enalean.com', 'mme.michue@enalean.com'));
$repo->setMailPrefix('["\\_o<"] \\t');
$this->assertIdentical(file_get_contents($this->_fixDir . '/gitolite-mail-config/mailhook-rev-mail-prefix-quote.txt'), $this->project_serializer->fetchMailHookConfig($prj, $repo));
}
示例2: 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();
}
示例3: 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;
}
示例4: testAddMailingShowRev
public function testAddMailingShowRev()
{
$GLOBALS['sys_https_host'] = 'codendi.org';
$prj = new MockProject($this);
$prj->setReturnValue('getId', 1750);
$repo = new GitRepository();
$repo->setPath('prj/repo.git');
$repo->setName('repo');
$repo->setProject($prj);
$repo->setId(290);
$driver = new MockGitDriver($this);
$driver->expectOnce('setConfig', array('/var/lib/codendi/gitroot/prj/repo.git', 'hooks.showrev', "t=%s; git show --name-status --pretty='format:URL: https://codendi.org/plugins/git/index.php/1750/view/290/?p=repo.git&a=commitdiff&h=%%H%%nAuthor: %%an <%%ae>%%nDate: %%aD%%n%%n%%s%%n%%b' \$t"));
$backend = new GitBackendTestVersion($this);
$backend->setUp($this->url_manager);
$backend->setGitRootPath(Git_Backend_Interface::GIT_ROOT_PATH);
$backend->setReturnValue('getDriver', $driver);
$backend->setUpMailingHook($repo);
}
示例5: 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;
}
}
示例6: _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
}
}
示例7: 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);
}
}
示例8: hydrateRepositoryObject
/**
* @deprecated Should use GitRepository::getInstanceFrom row instead.
* @param GitRepository $repository
* @param type $result
*/
public function hydrateRepositoryObject(GitRepository $repository, $result)
{
$repository->setName($result[self::REPOSITORY_NAME]);
$repository->setPath($result[self::REPOSITORY_PATH]);
$repository->setId($result[self::REPOSITORY_ID]);
$repository->setDescription($result[self::REPOSITORY_DESCRIPTION]);
$repository->setParentId($result[self::REPOSITORY_PARENT]);
$project = ProjectManager::instance()->getProject($result[self::FK_PROJECT_ID]);
$repository->setProject($project);
$repository->setCreationDate($result[self::REPOSITORY_CREATION_DATE]);
$user = UserManager::instance()->getUserById($result[self::REPOSITORY_CREATION_USER_ID]);
$repository->setCreator($user);
$repository->setIsInitialized($result[self::REPOSITORY_IS_INITIALIZED]);
$repository->setDeletionDate($result[self::REPOSITORY_DELETION_DATE]);
$repository->setAccess($result[self::REPOSITORY_ACCESS]);
$repository->setMailPrefix($result[self::REPOSITORY_MAIL_PREFIX]);
$repository->setBackendType($result[self::REPOSITORY_BACKEND_TYPE]);
$repository->setNamespace($result[self::REPOSITORY_NAMESPACE]);
$repository->setBackupPath($result[self::REPOSITORY_BACKUP_PATH]);
$repository->setScope($result[self::REPOSITORY_SCOPE]);
$repository->setRemoteServerId($result[self::REMOTE_SERVER_ID]);
$repository->setRemoteServerDisconnectDate($result[self::REMOTE_SERVER_DISCONNECT_DATE]);
$repository->setRemoteProjectDeletionDate($result[self::REMOTE_SERVER_DELETE_DATE]);
$repository->setRemoteServerMigrationStatus($result[self::REMOTE_SERVER_MIGRATION_STATUS]);
$repository->loadNotifiedMails();
/* Here just for reviewer test, will be replaced by real DB data in a future changeset*/
$result[self::ENABLE_ONLINE_EDIT] = false;
if ($result[self::ENABLE_ONLINE_EDIT] && GitConfig::instance()->isOnlineEditEnabled()) {
$repository->enableOnlineEdit();
}
}
示例9: 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;
}
}
示例10: 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;
}
}
示例11: hydrateRepositoryObject
public function hydrateRepositoryObject(GitRepository $repository, $result)
{
$repository->setName($result[self::REPOSITORY_NAME]);
$repository->setPath($result[self::REPOSITORY_PATH]);
$repository->setId($result[self::REPOSITORY_ID]);
$repository->setDescription($result[self::REPOSITORY_DESCRIPTION]);
$repository->setParentId($result[self::REPOSITORY_PARENT]);
$project = ProjectManager::instance()->getProject($result[self::FK_PROJECT_ID]);
$repository->setProject($project);
$repository->setCreationDate($result[self::REPOSITORY_CREATION_DATE]);
$user = UserManager::instance()->getUserById($result[self::REPOSITORY_CREATION_USER_ID]);
$repository->setCreator($user);
$repository->setIsInitialized($result[self::REPOSITORY_IS_INITIALIZED]);
$repository->setDeletionDate($result[self::REPOSITORY_DELETION_DATE]);
$repository->setAccess($result[self::REPOSITORY_ACCESS]);
$repository->setMailPrefix($result[self::REPOSITORY_MAIL_PREFIX]);
$repository->setBackendType($result[self::REPOSITORY_BACKEND_TYPE]);
$repository->setNamespace($result[self::REPOSITORY_NAMESPACE]);
$repository->setScope($result[self::REPOSITORY_SCOPE]);
$repository->loadNotifiedMails();
}
示例12: 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;
}
示例13: testSetUpRepositoryConfigWithRightRepoId
/**
* This is almost the same test than testAddMailingShowRev but
* through the higher level setUpRepository.
* What we want to be sure it that the right repository id is set.
*/
public function testSetUpRepositoryConfigWithRightRepoId()
{
$GLOBALS['sys_https_host'] = 'codendi.org';
$prj = new MockProject($this);
$prj->setReturnValue('getId', 1750);
// Use real git object because we need to store values (id)
$repo = new GitRepository();
$repo->setPath('prj/repo.git');
$repo->setName('repo');
$repo->setProject($prj);
$repo->setId(290);
$dao = new MockGitDao($this);
$dao->expectOnce('save');
$dao->setReturnValue('save', 290);
// The id we expect below
$driver = new MockGitDriver($this);
$driver->expectOnce('setConfig', array('/var/lib/codendi/gitroot/prj/repo.git', 'hooks.showrev', "t=%s; git show --name-status --pretty='format:URL: https://codendi.org/plugins/git/index.php/1750/view/290/?p=repo.git&a=commitdiff&h=%%H%%nAuthor: %%an <%%ae>%%nDate: %%aD%%n%%n%%s%%n%%b' \$t"));
$backend = new GitBackend4SetUp($this);
$backend->setUp($this->url_manager);
$backend->setGitRootPath(Git_Backend_Interface::GIT_ROOT_PATH);
$backend->setReturnValue('getDriver', $driver);
$backend->setReturnValue('getDao', $dao);
$backend->setUpRepository($repo);
}