本文整理汇总了PHP中Repository::loadById方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::loadById方法的具体用法?PHP Repository::loadById怎么用?PHP Repository::loadById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository::loadById方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLocalRepository
/**
* If this remote is a local paste, then we'll get the repository object
* returned
*
* @return Repository Repository object or NULL
*/
public function getLocalRepository()
{
if (!file_exists($this->arConfig['url'] . '/config')) {
return null;
}
$dir = basename($this->arConfig['url']);
if (substr($dir, -4) != '.git') {
//phorks are bare repositories "123.git"
return null;
}
$repo = new Repository();
$repo->loadById(substr($dir, 0, -4));
return $repo;
}
示例2: search
/**
* Search for a given term and return repositories that contain it
* in their description, file names or file content
*
* @param string $term Search term
* @param integer $page Page of search results, starting with 0
* @param integer $perPage Number of results per page
*
* @return Search_Result Search result object
*/
public function search($term, $page = 0, $perPage = 10)
{
$r = new Database_Adapter_Elasticsearch_HTTPRequest($this->searchInstance . 'repo/_search', \HTTP_Request2::METHOD_GET);
$r->setBody(json_encode((object) array('from' => $page * $perPage, 'size' => $perPage, 'query' => (object) array('bool' => (object) array('should' => array((object) array('query_string' => (object) array('query' => $term, 'default_operator' => 'AND')), (object) array('has_child' => (object) array('type' => 'file', 'query' => (object) array('query_string' => (object) array('query' => $term, 'default_operator' => 'AND'))))))))));
$httpRes = $r->send();
$jRes = json_decode($httpRes->getBody());
if (isset($jRes->error)) {
throw new Exception('Search exception: ' . $jRes->error, $jRes->status);
}
$sres = new Search_Result();
$sres->results = $jRes->hits->total;
$sres->page = $page;
$sres->perPage = $perPage;
foreach ($jRes->hits->hits as $hit) {
$r = new Repository();
//FIXME: error handling. what about deleted repos?
$r->loadById($hit->_source->id);
$sres->repos[] = $r;
}
return $sres;
}
示例3: getList
/**
* Get a list of repository objects
*
* @param integer $page Page number, beginning with 0, or "last"
* @param integer $perPage Number of repositories per page
*
* @return array Array of Repositories first, number of repositories second
*/
public function getList($page = 0, $perPage = 10)
{
chdir($this->gitDir);
$dirs = glob('*.git', GLOB_ONLYDIR);
sort($dirs, SORT_NUMERIC);
if ($page === 'last') {
//always show the last 10
$page = intval(count($dirs) / $perPage);
$start = count($dirs) - $perPage;
if ($start < 0) {
$start = 0;
}
$some = array_slice($dirs, $start, $perPage);
} else {
$some = array_slice($dirs, $page * $perPage, $perPage);
}
$repos = array();
foreach ($some as $oneDir) {
$r = new Repository();
$r->loadById(substr($oneDir, 0, -4));
$repos[] = $r;
}
return array($repos, count($dirs), $page);
}
示例4: localizeGitUrls
/**
* Convert an array of git urls to local URLs if possible and serialize them
* into a simple array.
*
* @param array $arGitUrls Array of array of urls. Main key is the title of
* the URL array.
*
* @return array Key is the git clone URL, value the title of the remote
*/
protected function localizeGitUrls($arGitUrls)
{
$pub = $pri = null;
if (isset($GLOBALS['phorkie']['cfg']['git']['public'])) {
$pub = $GLOBALS['phorkie']['cfg']['git']['public'];
}
if (isset($GLOBALS['phorkie']['cfg']['git']['private'])) {
$pri = $GLOBALS['phorkie']['cfg']['git']['private'];
}
$arRemoteCloneUrls = array();
foreach ($arGitUrls as $remoteTitle => $arUrls) {
foreach ($arUrls as $remoteCloneUrl) {
if ($pub !== null && substr($remoteCloneUrl, 0, strlen($pub)) == $pub && substr($remoteCloneUrl, -4) == '.git') {
$id = substr($remoteCloneUrl, strlen($pub), -4);
$repo = new Repository();
try {
$repo->loadById($id);
$arRemoteCloneUrls[$repo->gitDir] = $remoteTitle;
} catch (Exception $e) {
}
} else {
if ($pri !== null && substr($remoteCloneUrl, 0, strlen($pri)) == $pri && substr($remoteCloneUrl, -4) == '.git') {
$id = substr($remoteCloneUrl, strlen($pri), -4);
$repo = new Repository();
try {
$repo->loadById($id);
$arRemoteCloneUrls[$repo->gitDir] = $remoteTitle;
} catch (Exception $e) {
}
} else {
$arRemoteCloneUrls[$remoteCloneUrl] = $remoteTitle;
}
}
}
}
return $arRemoteCloneUrls;
}
示例5: header
}
}
if (!isset($_GET['maxheight'])) {
$maxHeight = 900;
} else {
$maxHeight = (int) $_GET['maxheight'];
if ($maxHeight <= 100) {
header('HTTP/1.0 400 Bad Request');
echo "maxheight parameter too small\n";
exit(1);
}
}
$parts = explode('/', $_GET['url']);
$id = end($parts);
$repo = new Repository();
$repo->loadById($id);
if ($format == 'json') {
$data = new \stdClass();
} else {
$data = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8" standalone="yes"?>' . '<oembed/>');
}
$data->type = 'rich';
$data->version = '1.0';
$data->provider_name = 'phorkie';
$data->provider_url = Tools::fullUrl();
$data->title = $repo->getTitle();
$author = $repo->getOwner();
$data->author_name = $author['name'];
$data->cache_age = 86400;
$data->width = $maxWidth;
$data->height = $maxHeight;