本文整理汇总了PHP中PhabricatorRepository::parseRepositoryServicePath方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorRepository::parseRepositoryServicePath方法的具体用法?PHP PhabricatorRepository::parseRepositoryServicePath怎么用?PHP PhabricatorRepository::parseRepositoryServicePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorRepository
的用法示例。
在下文中一共展示了PhabricatorRepository::parseRepositoryServicePath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadRepositoryWithPath
protected function loadRepositoryWithPath($path)
{
$viewer = $this->getUser();
$info = PhabricatorRepository::parseRepositoryServicePath($path);
if ($info === null) {
throw new Exception(pht('Unrecognized repository path "%s". Expected a path like "%s" ' . 'or "%s".', $path, '/diffusion/X/', '/diffusion/123/'));
}
$identifier = $info['identifier'];
$base = $info['base'];
$this->baseRequestPath = $base;
$repository = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->withIdentifiers(array($identifier))->needURIs(true)->executeOne();
if (!$repository) {
throw new Exception(pht('No repository "%s" exists!', $identifier));
}
$protocol = PhabricatorRepositoryURI::BUILTIN_PROTOCOL_SSH;
if (!$repository->canServeProtocol($protocol, false)) {
throw new Exception(pht('This repository ("%s") is not available over SSH.', $repository->getDisplayName()));
}
return $repository;
}
示例2: getRequestDirectoryPath
private function getRequestDirectoryPath(PhabricatorRepository $repository)
{
$request = $this->getRequest();
$request_path = $request->getRequestURI()->getPath();
$info = PhabricatorRepository::parseRepositoryServicePath($request_path, $repository->getVersionControlSystem());
$base_path = $info['path'];
// For Git repositories, strip an optional directory component if it
// isn't the name of a known Git resource. This allows users to clone
// repositories as "/diffusion/X/anything.git", for example.
if ($repository->isGit()) {
$known = array('info', 'git-upload-pack', 'git-receive-pack');
foreach ($known as $key => $path) {
$known[$key] = preg_quote($path, '@');
}
$known = implode('|', $known);
if (preg_match('@^/([^/]+)/(' . $known . ')(/|$)@', $base_path)) {
$base_path = preg_replace('@^/([^/]+)@', '', $base_path);
}
}
return $base_path;
}
示例3: loadRepositoryWithPath
protected function loadRepositoryWithPath($path)
{
$viewer = $this->getUser();
$info = PhabricatorRepository::parseRepositoryServicePath($path);
if ($info === null) {
throw new Exception(pht('Unrecognized repository path "%s". Expected a path like "%s" ' . 'or "%s".', $path, '/diffusion/X/', '/diffusion/123/'));
}
$identifier = $info['identifier'];
$base = $info['base'];
$this->baseRequestPath = $base;
$repository = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->withIdentifiers(array($identifier))->executeOne();
if (!$repository) {
throw new Exception(pht('No repository "%s" exists!', $identifier));
}
switch ($repository->getServeOverSSH()) {
case PhabricatorRepository::SERVE_READONLY:
case PhabricatorRepository::SERVE_READWRITE:
// If we have read or read/write access, proceed for now. We will
// check write access when the user actually issues a write command.
break;
case PhabricatorRepository::SERVE_OFF:
default:
throw new Exception(pht('This repository ("%s") is not available over SSH.', $repository->getDisplayName()));
}
return $repository;
}