本文整理汇总了PHP中AgaviToolkit::isPortNecessary方法的典型用法代码示例。如果您正苦于以下问题:PHP AgaviToolkit::isPortNecessary方法的具体用法?PHP AgaviToolkit::isPortNecessary怎么用?PHP AgaviToolkit::isPortNecessary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AgaviToolkit
的用法示例。
在下文中一共展示了AgaviToolkit::isPortNecessary方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIsPortNecessary
public function testIsPortNecessary()
{
$this->assertTrue(AgaviToolkit::isPortNecessary('some scheme', 8800));
$this->assertFalse(AgaviToolkit::isPortNecessary('ftp', 21));
$this->assertFalse(AgaviToolkit::isPortNecessary('ssh', 22));
$this->assertFalse(AgaviToolkit::isPortNecessary('https', 443));
$this->assertFalse(AgaviToolkit::isPortNecessary('nttp', 119));
}
示例2: getUrlAuthority
/**
* Retrieve the request URL authority, typically host and port.
* Example: "foo.example.com:8080".
*
* @param bool Whether or not ports 80 (for HTTP) and 433 (for HTTPS)
* should be included in the return string.
*
* @return string The request URL authority.
*
* @author David Zülke <dz@bitxtender.com>
* @since 0.11.0
*/
public function getUrlAuthority($forcePort = false)
{
$port = $this->getUrlPort();
$scheme = $this->getUrlScheme();
return $this->getUrlHost() . ($forcePort || AgaviToolkit::isPortNecessary($scheme, $port) ? ':' . $port : '');
}
示例3: gen
//.........这里部分代码省略.........
if ($append !== '') {
$append = '?' . $append;
}
}
} else {
// the route exists, but we must create a normal index.php?foo=bar URL.
$isNullRoute = false;
$routes = $this->getAffectedRoutes($route, $isNullRoute);
if ($isNullRoute) {
$params = array_merge($this->inputParameters, $params);
}
if (count($routes) == 0) {
$path = $route;
}
// we collect the default parameters from the route and make sure
// new parameters don't overwrite already defined parameters
$defaults = array();
$ma = $req->getParameter('module_accessor');
$aa = $req->getParameter('action_accessor');
foreach ($routes as $route) {
if (isset($this->routes[$route])) {
$r = $this->routes[$route];
$myDefaults = array();
foreach ($r['opt']['defaults'] as $key => $default) {
$myDefaults[$key] = $default->getValue();
}
if ($r['opt']['module']) {
$myDefaults[$ma] = $r['opt']['module'];
}
if ($r['opt']['action']) {
$myDefaults[$aa] = $r['opt']['action'];
}
$defaults = array_merge($myDefaults, $defaults);
}
}
$params = array_merge($defaults, $params);
}
if (!isset($path)) {
// the route does not exist. we generate a normal index.php?foo=bar URL.
$path = $_SERVER['SCRIPT_NAME'];
}
if (!isset($path)) {
// routing was off; the name of the route is the input
}
if (!isset($append)) {
$append = '?' . http_build_query($params, '', $aso);
}
$retval = $path . $append;
}
if (!$options['relative'] || $options['relative'] && ($options['scheme'] !== null || $options['authority'] !== null || $options['host'] !== null || $options['port'] !== null)) {
$scheme = false;
if ($options['scheme'] !== false) {
$scheme = $options['scheme'] === null ? $req->getUrlScheme() : $options['scheme'];
}
$authority = '';
if ($options['authority'] === null) {
if ($options['host'] !== null && $options['host'] !== false) {
$authority = $options['host'];
} elseif ($options['host'] === false) {
$authority = '';
} else {
$authority = $req->getUrlHost();
}
$port = null;
if ($options['port'] !== null && $options['port'] !== false) {
if (AgaviToolkit::isPortNecessary($options['scheme'] !== null && $options['scheme'] !== false ? $options['scheme'] : $req->getUrlScheme(), $options['port'])) {
$port = $options['port'];
} else {
$port = null;
}
} elseif ($options['port'] === false) {
$port = null;
} elseif ($options['scheme'] === null) {
if (!AgaviToolkit::isPortNecessary($req->getUrlScheme(), $port = $req->getUrlPort())) {
$port = null;
}
}
if ($port !== null) {
$authority .= ':' . $port;
}
} elseif ($options['authority'] !== false) {
$authority = $options['authority'];
}
if ($scheme === false) {
// nothing at all, e.g. when displaying a URL without the "http://" prefix
$scheme = '';
} elseif (trim($scheme) === '') {
// a protocol-relative URL (see #1224)
$scheme = '//';
} else {
// given scheme plus "://"
$scheme = $scheme . '://';
}
$retval = $scheme . $authority . $retval;
}
if ($options['fragment'] !== null) {
$retval .= '#' . $options['fragment'];
}
return $retval;
}