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


PHP AgaviToolkit::isPortNecessary方法代码示例

本文整理汇总了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));
 }
开发者ID:horros,项目名称:agavi,代码行数:8,代码来源:AgaviToolkitTest.php

示例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 : '');
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:18,代码来源:AgaviWebRequest.class.php

示例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;
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:101,代码来源:AgaviWebRouting.class.php


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