本文整理汇总了PHP中GitRepository::create方法的典型用法代码示例。如果您正苦于以下问题:PHP GitRepository::create方法的具体用法?PHP GitRepository::create怎么用?PHP GitRepository::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GitRepository
的用法示例。
在下文中一共展示了GitRepository::create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process()
{
global $sys_allow_restricted_users;
$parameters = $this->getParametersAsArray();
$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;
}
$userId = 0;
if (!empty($parameters[2])) {
$userId = $parameters[2];
} else {
$this->error('Missing argument user id');
return false;
}
try {
$repository = new GitRepository();
$repository->setBackend(Backend::instance('Git', 'GitBackend'));
$repository->setDescription('-- Default description --');
//default access is private when restricted users are allowed
if ($sys_allow_restricted_users == 1) {
$repository->setAccess(GitRepository::PRIVATE_ACCESS);
} else {
$repository->setAccess(GitRepository::PUBLIC_ACCESS);
}
$user = null;
if (!empty($userId)) {
$user = UserManager::instance()->getUserById($userId);
}
if (!empty($user)) {
$repository->setCreator($user);
}
$repository->setProject($project);
$repository->setName($repositoryName);
$repository->create();
$this->done();
} catch (GitDaoException $e) {
$this->error($e->getMessage());
return false;
} catch (GitDriverException $e) {
$this->error($e->getMessage());
return false;
} catch (GitBackendException $e) {
$this->error($e->getMessage());
return false;
} catch (Exception $e) {
$this->error($e->getMessage());
return false;
}
}
示例2: cloneRepository
/**
* @param string $cloneUrl
* @param string $directory
* @param array $options
* @param array $arguments
* @return GitRepository
*/
public function cloneRepository($cloneUrl, $directory = null, array $options = [], array $arguments = [])
{
if ($directory === null) {
$pathinfo = pathinfo($cloneUrl);
$directory = getcwd() . DIRECTORY_SEPARATOR . $pathinfo['filename'];
}
$gitRepository = new GitRepository($this, $directory);
$gitRepository->create($cloneUrl, $options, $arguments);
return $gitRepository;
}