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


PHP PhutilURI::setPath方法代码示例

本文整理汇总了PHP中PhutilURI::setPath方法的典型用法代码示例。如果您正苦于以下问题:PHP PhutilURI::setPath方法的具体用法?PHP PhutilURI::setPath怎么用?PHP PhutilURI::setPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhutilURI的用法示例。


在下文中一共展示了PhutilURI::setPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getProxiedFuture

 protected function getProxiedFuture()
 {
     if (!$this->future) {
         $params = $this->params;
         if (!$this->action) {
             throw new Exception(pht('You must %s!', 'setRawGitHubQuery()'));
         }
         if (!$this->accessToken) {
             throw new Exception(pht('You must %s!', 'setAccessToken()'));
         }
         $uri = new PhutilURI('https://api.github.com/');
         $uri->setPath('/' . ltrim($this->action, '/'));
         $future = new HTTPSFuture($uri);
         $future->setData($this->params);
         $future->addHeader('Authorization', 'token ' . $this->accessToken);
         // NOTE: GitHub requires a 'User-Agent' header.
         $future->addHeader('User-Agent', __CLASS__);
         $future->setMethod($this->method);
         foreach ($this->headers as $header) {
             list($key, $value) = $header;
             $future->addHeader($key, $value);
         }
         $this->future = $future;
     }
     return $this->future;
 }
开发者ID:endlessm,项目名称:libphutil,代码行数:26,代码来源:PhutilGitHubFuture.php

示例2: getServerStatus

 public static function getServerStatus()
 {
     $uri = PhabricatorEnv::getEnvConfig('notification.server-uri');
     $uri = new PhutilURI($uri);
     $uri->setPath('/status/');
     list($body) = id(new HTTPSFuture($uri))->setTimeout(3)->resolvex();
     $status = json_decode($body, true);
     if (!is_array($status)) {
         throw new Exception(pht('Expected JSON response from notification server, received: %s', $body));
     }
     return $status;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:12,代码来源:PhabricatorNotificationClient.php

示例3: run

 protected function run()
 {
     $argv = $this->getArgv();
     if (count($argv) !== 1) {
         throw new Exception(pht('Usage: %s %s', __CLASS__, '<json_config_file>'));
     }
     $json_raw = Filesystem::readFile($argv[0]);
     try {
         $config = phutil_json_decode($json_raw);
     } catch (PhutilJSONParserException $ex) {
         throw new PhutilProxyException(pht("File '%s' is not valid JSON!", $argv[0]), $ex);
     }
     $nick = idx($config, 'nick', 'phabot');
     $handlers = idx($config, 'handlers', array());
     $protocol_adapter_class = idx($config, 'protocol-adapter', 'PhabricatorIRCProtocolAdapter');
     $this->pollFrequency = idx($config, 'poll-frequency', 1);
     $this->config = $config;
     foreach ($handlers as $handler) {
         $obj = newv($handler, array($this));
         $this->handlers[] = $obj;
     }
     $ca_bundle = idx($config, 'https.cabundle');
     if ($ca_bundle) {
         HTTPSFuture::setGlobalCABundleFromPath($ca_bundle);
     }
     $conduit_uri = idx($config, 'conduit.uri');
     if ($conduit_uri) {
         $conduit_token = idx($config, 'conduit.token');
         // Normalize the path component of the URI so users can enter the
         // domain without the "/api/" part.
         $conduit_uri = new PhutilURI($conduit_uri);
         $conduit_host = (string) $conduit_uri->setPath('/');
         $conduit_uri = (string) $conduit_uri->setPath('/api/');
         $conduit = new ConduitClient($conduit_uri);
         if ($conduit_token) {
             $conduit->setConduitToken($conduit_token);
         } else {
             $conduit_user = idx($config, 'conduit.user');
             $conduit_cert = idx($config, 'conduit.cert');
             $response = $conduit->callMethodSynchronous('conduit.connect', array('client' => __CLASS__, 'clientVersion' => '1.0', 'clientDescription' => php_uname('n') . ':' . $nick, 'host' => $conduit_host, 'user' => $conduit_user, 'certificate' => $conduit_cert));
         }
         $this->conduit = $conduit;
     }
     // Instantiate Protocol Adapter, for now follow same technique as
     // handler instantiation
     $this->protocolAdapter = newv($protocol_adapter_class, array());
     $this->protocolAdapter->setConfig($this->config)->connect();
     $this->runLoop();
     $this->protocolAdapter->disconnect();
 }
开发者ID:pugong,项目名称:phabricator,代码行数:50,代码来源:PhabricatorBot.php

示例4: getRedirectURI

 public function getRedirectURI()
 {
     if (strlen($this->getAlias())) {
         $path = '/u/' . $this->getAlias();
     } else {
         $path = '/u/' . $this->getID();
     }
     $short_domain = PhabricatorEnv::getEnvConfig('phurl.short-uri');
     if (!$short_domain) {
         return $path;
     }
     $uri = new PhutilURI($short_domain);
     $uri->setPath($path);
     return (string) $uri;
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:15,代码来源:PhabricatorPhurlURL.php

示例5: validateHost

 protected function validateHost($host)
 {
     if (!$host) {
         // If the client doesn't send a host key, don't complain. We should in
         // the future, but this change isn't severe enough to bump the protocol
         // version.
         // TODO: Remove this once the protocol version gets bumped past 2 (i.e.,
         // require the host key be present and valid).
         return;
     }
     $host = new PhutilURI($host);
     $host->setPath('/');
     $host = (string) $host;
     $self = PhabricatorEnv::getProductionURI('/');
     if ($self !== $host) {
         throw new Exception("Your client is connecting to this install as '{$host}', but it is " . "configured as '{$self}'. The client and server must use the exact " . "same URI to identify the install. Edit your .arcconfig or " . "phabricator/conf so they agree on the URI for the install.");
     }
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:18,代码来源:ConduitAPIMethod.php

示例6: getProxiedFuture

 protected function getProxiedFuture()
 {
     if (!$this->future) {
         $params = $this->params;
         if (!$this->action) {
             throw new Exception(pht('You must %s!', 'setRawSlackQuery()'));
         }
         if (!$this->accessToken) {
             throw new Exception(pht('You must %s!', 'setAccessToken()'));
         }
         $uri = new PhutilURI('https://slack.com/');
         $uri->setPath('/api/' . $this->action);
         $uri->setQueryParam('token', $this->accessToken);
         $future = new HTTPSFuture($uri);
         $future->setData($this->params);
         $future->setMethod($this->method);
         $this->future = $future;
     }
     return $this->future;
 }
开发者ID:endlessm,项目名称:libphutil,代码行数:20,代码来源:PhutilSlackFuture.php

示例7: processRequest

 public function processRequest()
 {
     $uri = PhabricatorEnv::getEnvConfig('notification.server-uri');
     $uri = new PhutilURI($uri);
     $uri->setPath('/status/');
     $future = id(new HTTPSFuture($uri))->setTimeout(3);
     try {
         list($body) = $future->resolvex();
         $body = json_decode($body, true);
         if (!is_array($body)) {
             throw new Exception("Expected JSON response from server!");
         }
         $status = $this->renderServerStatus($body);
     } catch (Exception $ex) {
         $status = new AphrontErrorView();
         $status->setTitle("Notification Server Issue");
         $status->appendChild('Unable to determine server status. This probably means the server ' . 'is not in great shape. The specific issue encountered was:' . '<br />' . '<br />' . '<strong>' . phutil_escape_html(get_class($ex)) . '</strong> ' . nl2br(phutil_escape_html($ex->getMessage())));
     }
     return $this->buildStandardPageResponse($status, array('title' => 'Aphlict Server Status'));
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:20,代码来源:PhabricatorNotificationStatusController.php

示例8: getProxiedFuture

 protected function getProxiedFuture()
 {
     if (!$this->future) {
         $params = $this->params;
         if (!$this->action) {
             throw new Exception(pht('You must %s!', 'setRawAsanaQuery()'));
         }
         if (!$this->accessToken) {
             throw new Exception(pht('You must %s!', 'setAccessToken()'));
         }
         $uri = new PhutilURI('https://app.asana.com/');
         $uri->setPath('/api/1.0/' . ltrim($this->action, '/'));
         $future = new HTTPSFuture($uri);
         $future->setData($this->params);
         $future->addHeader('Authorization', 'Bearer ' . $this->accessToken);
         $future->setMethod($this->method);
         $this->future = $future;
     }
     return $this->future;
 }
开发者ID:barcelonascience,项目名称:libphutil,代码行数:20,代码来源:PhutilAsanaFuture.php

示例9: getProxiedFuture

 protected function getProxiedFuture()
 {
     if (!$this->future) {
         $params = $this->params;
         if (!$this->action) {
             throw new Exception("You must setRawWordPressQuery()!");
         }
         if (!$this->accessToken) {
             throw new Exception("You must setAccessToken()!");
         }
         $uri = new PhutilURI('https://public-api.wordpress.com/');
         $uri->setPath('/rest/v1/' . ltrim($this->action, '/'));
         $future = new HTTPSFuture($uri);
         $future->setData($this->params);
         $future->setMethod($this->method);
         // NOTE: This is how WordPress.com REST API authenticates
         $future->addHeader('Authorization', 'Bearer ' . $this->accessToken);
         $this->future = $future;
     }
     return $this->future;
 }
开发者ID:jasteele12,项目名称:prb_lint_tests,代码行数:21,代码来源:PhutilWordPressFuture.php

示例10: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $alt = PhabricatorEnv::getEnvConfig('security.alternate-file-domain');
     $uri = new PhutilURI($alt);
     $alt_domain = $uri->getDomain();
     if ($alt_domain && $alt_domain != $request->getHost()) {
         return id(new AphrontRedirectResponse())->setURI($uri->setPath($request->getPath()));
     }
     $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $this->phid);
     if (!$file) {
         return new Aphront404Response();
     }
     if (!$file->validateSecretKey($this->key)) {
         return new Aphront403Response();
     }
     $data = $file->loadFileData();
     $response = new AphrontFileResponse();
     $response->setContent($data);
     $response->setCacheDurationInSeconds(60 * 60 * 24 * 30);
     $is_view = $file->isViewableInBrowser();
     if ($is_view) {
         $response->setMimeType($file->getViewableMimeType());
     } else {
         if (!$request->isHTTPPost()) {
             // NOTE: Require POST to download files. We'd rather go full-bore and
             // do a real CSRF check, but can't currently authenticate users on the
             // file domain. This should blunt any attacks based on iframes, script
             // tags, applet tags, etc., at least. Send the user to the "info" page
             // if they're using some other method.
             return id(new AphrontRedirectResponse())->setURI(PhabricatorEnv::getProductionURI($file->getBestURI()));
         }
         $response->setMimeType($file->getMimeType());
         $response->setDownload($file->getName());
     }
     return $response;
 }
开发者ID:ruckfull,项目名称:phabricator,代码行数:37,代码来源:PhabricatorFileDataController.php

示例11: getProxiedFuture

 protected function getProxiedFuture()
 {
     if (!$this->future) {
         $params = $this->params;
         if (!$this->action) {
             throw new Exception('You must setRawTwitchQuery()!');
         }
         if (!$this->accessToken) {
             throw new Exception('You must setAccessToken()!');
         }
         $uri = new PhutilURI('https://api.twitch.tv/');
         $uri->setPath('/kraken/' . ltrim($this->action, '/'));
         $uri->setQueryParam('oauth_token', $this->accessToken);
         $future = new HTTPSFuture($uri);
         $future->setData($this->params);
         $future->setMethod($this->method);
         // NOTE: This is how the Twitch API is versioned.
         $future->addHeader('Accept', 'application/vnd.twitchtv.2+json');
         // NOTE: This is required to avoid rate limiting.
         $future->addHeader('Client-ID', $this->clientID);
         $this->future = $future;
     }
     return $this->future;
 }
开发者ID:lsubra,项目名称:libphutil,代码行数:24,代码来源:PhutilTwitchFuture.php

示例12: getViewURI

 public function getViewURI()
 {
     if (!$this->getPHID()) {
         throw new Exception("You must save a file before you can generate a view URI.");
     }
     $alt = PhabricatorEnv::getEnvConfig('security.alternate-file-domain');
     if ($alt) {
         $path = '/file/alt/' . $this->getSecretKey() . '/' . $this->getPHID() . '/';
         $uri = new PhutilURI($alt);
         $uri->setPath($path);
         return (string) $uri;
     } else {
         return '/file/view/' . $this->getPHID() . '/';
     }
 }
开发者ID:netcomtec,项目名称:phabricator,代码行数:15,代码来源:PhabricatorFile.php

示例13: getURIObject

 private function getURIObject()
 {
     // Users can provide Git/SCP-style URIs in the form "user@host:path".
     // In the general case, these are not equivalent to any "ssh://..." form
     // because the path is relative.
     if ($this->isBuiltin()) {
         $builtin_protocol = $this->getForcedProtocol();
         $builtin_domain = $this->getForcedHost();
         $raw_uri = "{$builtin_protocol}://{$builtin_domain}";
     } else {
         $raw_uri = $this->getURI();
     }
     $port = $this->getForcedPort();
     $default_ports = array('ssh' => 22, 'http' => 80, 'https' => 443);
     $uri = new PhutilURI($raw_uri);
     // Make sure to remove any password from the URI before we do anything
     // with it; this should always be provided by the associated credential.
     $uri->setPass(null);
     $protocol = $this->getForcedProtocol();
     if ($protocol) {
         $uri->setProtocol($protocol);
     }
     if ($port) {
         $uri->setPort($port);
     }
     // Remove any explicitly set default ports.
     $uri_port = $uri->getPort();
     $uri_protocol = $uri->getProtocol();
     $uri_default = idx($default_ports, $uri_protocol);
     if ($uri_default && $uri_default == $uri_port) {
         $uri->setPort(null);
     }
     $user = $this->getForcedUser();
     if ($user) {
         $uri->setUser($user);
     }
     $host = $this->getForcedHost();
     if ($host) {
         $uri->setDomain($host);
     }
     $path = $this->getForcedPath();
     if ($path) {
         $uri->setPath($path);
     }
     return $uri;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:46,代码来源:PhabricatorRepositoryURI.php

示例14: PhutilURI

 if ($force_conduit) {
     $conduit_uri = $force_conduit;
 } else {
     $conduit_uri = $configuration_manager->getConfigFromAnySource('phabricator.uri');
     if ($conduit_uri === null) {
         $conduit_uri = $configuration_manager->getConfigFromAnySource('default');
     }
 }
 if ($conduit_uri) {
     // Set the URI path to '/api/'. TODO: Originally, I contemplated letting
     // you deploy Phabricator somewhere other than the domain root, but ended
     // up never pursuing that. We should get rid of all "/api/" silliness
     // in things users are expected to configure. This is already happening
     // to some degree, e.g. "arc install-certificate" does it for you.
     $conduit_uri = new PhutilURI($conduit_uri);
     $conduit_uri->setPath('/api/');
     $conduit_uri = (string) $conduit_uri;
 }
 $workflow->setConduitURI($conduit_uri);
 // Apply global CA bundle from configs.
 $ca_bundle = $configuration_manager->getConfigFromAnySource('https.cabundle');
 if ($ca_bundle) {
     $ca_bundle = Filesystem::resolvePath($ca_bundle, $working_copy->getProjectRoot());
     HTTPSFuture::setGlobalCABundleFromPath($ca_bundle);
 }
 $blind_key = 'https.blindly-trust-domains';
 $blind_trust = $configuration_manager->getConfigFromAnySource($blind_key);
 if ($blind_trust) {
     HTTPSFuture::setBlindlyTrustDomains($blind_trust);
 }
 if ($need_conduit) {
开发者ID:ivoryxiong,项目名称:arcanist,代码行数:31,代码来源:arcanist.php

示例15: makeInternalURI

 private function makeInternalURI($uri_string)
 {
     $uri = new PhutilURI($uri_string);
     $proto = $uri->getProtocol();
     if ($proto !== 'svn+ssh') {
         throw new Exception(pht('Protocol for URI "%s" MUST be "svn+ssh".', $uri_string));
     }
     $path = $uri->getPath();
     // Subversion presumably deals with this, but make sure there's nothing
     // skethcy going on with the URI.
     if (preg_match('(/\\.\\./)', $path)) {
         throw new Exception(pht('String "/../" is invalid in path specification "%s".', $uri_string));
     }
     $repository = $this->loadRepository($path);
     $path = preg_replace('(^/diffusion/[A-Z]+)', rtrim($repository->getLocalPath(), '/'), $path);
     if (preg_match('(^/diffusion/[A-Z]+/\\z)', $path)) {
         $path = rtrim($path, '/');
     }
     $uri->setPath($path);
     // If this is happening during the handshake, these are the base URIs for
     // the request.
     if ($this->externalBaseURI === null) {
         $pre = (string) id(clone $uri)->setPath('');
         $this->externalBaseURI = $pre . '/diffusion/' . $repository->getCallsign();
         $this->internalBaseURI = $pre . rtrim($repository->getLocalPath(), '/');
     }
     return (string) $uri;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:28,代码来源:DiffusionSSHSubversionServeWorkflow.php


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