当前位置: 首页>>代码示例>>PHP>>正文


PHP Repository::loadById方法代码示例

本文整理汇总了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;
 }
开发者ID:nickel715,项目名称:phorkie,代码行数:20,代码来源:Remote.php

示例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;
 }
开发者ID:nickel715,项目名称:phorkie,代码行数:31,代码来源:Search.php

示例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);
 }
开发者ID:nickel715,项目名称:phorkie,代码行数:32,代码来源:Repositories.php

示例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;
 }
开发者ID:nickel715,项目名称:phorkie,代码行数:46,代码来源:LinkbackReceiver.php

示例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;
开发者ID:nickel715,项目名称:phorkie,代码行数:31,代码来源:oembed.php


注:本文中的Repository::loadById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。