本文整理汇总了PHP中Repository::getLink方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::getLink方法的具体用法?PHP Repository::getLink怎么用?PHP Repository::getLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository::getLink方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Send linkback on "create" events to remote repositories
*/
public function send($event, Repository $repo)
{
if ($this->config === false) {
return;
}
if ($event != 'create') {
return;
}
$origin = $repo->getConnectionInfo()->getOrigin();
if ($origin === null) {
return;
}
$originWebUrl = $origin->getWebUrl(true);
if ($originWebUrl === null) {
return;
}
$this->pbc = new \PEAR2\Services\Linkback\Client();
$req = $this->pbc->getRequest();
$req->setConfig(array('ssl_verify_peer' => false, 'ssl_verify_host' => false));
$this->pbc->setRequestTemplate($req);
$req->setHeader('user-agent', 'phorkie');
try {
$res = $this->pbc->send($repo->getLink('display', null, true), $originWebUrl);
} catch (\Exception $e) {
//FIXME: log errors
}
}
示例2: send
/**
* Call webhook URLs with our payload
*/
public function send($event, Repository $repo)
{
if (count($this->config) == 0) {
return;
}
/* slightly inspired by
https://help.github.com/articles/post-receive-hooks */
$payload = (object) array('event' => $event, 'author' => array('name' => $_SESSION['name'], 'email' => $_SESSION['email']), 'repository' => array('name' => $repo->getTitle(), 'url' => $repo->getLink('display', null, true), 'description' => $repo->getDescription(), 'owner' => $repo->getOwner()));
foreach ($this->config as $url) {
$req = new \HTTP_Request2($url);
$req->setMethod(\HTTP_Request2::METHOD_POST)->setHeader('Content-Type: application/vnd.phorkie.webhook+json')->setBody(json_encode($payload));
try {
$response = $req->send();
//FIXME log response codes != 200
} catch (HTTP_Request2_Exception $e) {
//FIXME log exceptions
}
}
}
示例3: redirect
if ($_GET['file'] == 'newfile') {
$file = 'newfile';
} else {
$file = $repo->getFileByName($_GET['file']);
}
}
$repopo = new Repository_Post($repo);
if ($repopo->process($_POST, $_SESSION)) {
$anchor = '';
if ($file instanceof File) {
if (isset($repopo->renameMap[$file->getFilename()])) {
$anchor = '#' . $repo->getFileByName($repopo->renameMap[$file->getFilename()])->getAnchorName();
} else {
$anchor = '#' . $file->getAnchorName();
}
} else {
if ($file === 'newfile' && $repopo->newfileName) {
$anchor = '#' . $repo->getFileByName($repopo->newfileName)->getAnchorName();
}
}
redirect($repo->getLink('display', null, true) . $anchor);
}
$actionFile = null;
if ($file instanceof File) {
$actionFile = $file->getFilename();
} else {
if ($file === 'newfile') {
$actionFile = 'newfile';
}
}
render('edit', array('repo' => $repo, 'singlefile' => $file, 'dh' => new \Date_HumanDiff(), 'htmlhelper' => new HtmlHelper(), 'formaction' => $repo->getLink('edit', $actionFile)));
示例4: Repository
<?php
namespace phorkie;
/**
* Display DOAP of the paste.
* Contains a machine-readable project description with Git URL.
*/
$reqWritePermissions = false;
require_once 'www-header.php';
$repo = new Repository();
$repo->loadFromRequest();
header('Content-Type: application/rdf+xml');
render('doap', array('repo' => $repo, 'date' => date('Y-m-d', end($repo->getHistory())->committerTime), 'link' => Tools::fullUrl($repo->getLink('display'))));
示例5: Repository
<?php
namespace phorkie;
/**
* Display paste contents
*/
$reqWritePermissions = false;
require_once 'www-header.php';
$repo = new Repository();
$repo->loadFromRequest();
header('X-Pingback: ' . $repo->getLink('linkback', null, true));
header('Link: <' . $repo->getLink('linkback', null, true) . '>;' . 'rel="http://webmention.org/"');
render('display', array('repo' => $repo, 'dh' => new \Date_HumanDiff(), 'htmlhelper' => new HtmlHelper(), 'domain' => $_SERVER['HTTP_HOST'], 'flashmessages' => FlashMessage::getAll()));
示例6: getRepositoryEmbedCode
public function getRepositoryEmbedCode(Repository $repo)
{
return '<script src="' . $repo->getLink('embed', null, true) . '"' . ' id="phork-script-' . $repo->id . '"' . ' type="text/javascript"></script>';
}