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


PHP path::glue方法代码示例

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


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

示例1: testGlue

 public function testGlue()
 {
     $this->assertEquals('a', path::glue('a'));
     $this->assertEquals('a', path::glue('a', ''));
     $this->assertEquals('a', path::glue('', 'a'));
     $this->assertEquals('a', path::glue('', 'a', ''));
     $this->assertEquals('a/b', path::glue('a/b'));
     $this->assertEquals('a/b', path::glue('a/b', ''));
     $this->assertEquals('a/b', path::glue('', 'a/b'));
     $this->assertEquals('a/b', path::glue('', 'a/b', ''));
     $this->assertEquals('a/b', path::glue('a', 'b'));
     $this->assertEquals('a/b', path::glue('a', '/b'));
     $this->assertEquals('a/b', path::glue('a/', 'b'));
     $this->assertEquals('a/b', path::glue('a/', '/b'));
     $this->assertEquals('alPHA/bETa', path::glue('alPHA', 'bETa'));
     $this->assertEquals('alPHA/bETa', path::glue('alPHA/', 'bETa'));
     $this->assertEquals('alPHA/bETa', path::glue('alPHA', '/bETa'));
     $this->assertEquals('alPHA/bETa', path::glue('alPHA/', '/bETa'));
     $this->assertEquals('alPHA/bETa', path::glue('alPHA//', '/bETa'));
     $this->assertEquals('alPHA/bETa', path::glue('alPHA//', '//bETa'));
     $this->assertEquals('/alPHA/bETa', path::glue('/alPHA//', '/bETa'));
     $this->assertEquals('/alPHA/bETa', path::glue('/alPHA//', '//bETa'));
     $this->assertEquals('//alPHA/bETa', path::glue('//alPHA//', '//bETa'));
     $this->assertEquals('//alPHA/bETa', path::glue('//alPHA//', '////bETa'));
     $this->assertEquals('////alPHA/bETa', path::glue('////alPHA//', '////bETa'));
     $this->assertEquals('/alPHA/bETa', path::glue('', '/alPHA//', '/bETa'));
     $this->assertEquals('/alPHA/bETa', path::glue('', '/alPHA//', '//bETa'));
     $this->assertEquals('alPHA/bETa/gaMMa', path::glue('alPHA//', '/bETa/gaMMa'));
     $this->assertEquals('alPHA/bETa/gaMMa', path::glue('alPHA//', '//bETa/gaMMa'));
     $this->assertEquals('alPHA/bETa/gaMMa', path::glue('alPHA//', '/bETa/gaMMa/'));
     $this->assertEquals('alPHA/bETa/gaMMa', path::glue('alPHA//', '//bETa/gaMMa/', ''));
     $this->assertEquals('alPHA/bETa/gaMMa', path::glue('alPHA//', '/bETa/gaMMa///'));
     $this->assertEquals('alPHA/bETa/gaMMa', path::glue('alPHA//', '//bETa/gaMMa///', ''));
 }
开发者ID:cepharum,项目名称:txf,代码行数:34,代码来源:pathTest.php

示例2: __get

 public function __get($name)
 {
     switch ($name) {
         case 'name':
             return $this->name;
         case 'version':
             if (is_null($this->version)) {
                 $versionFile = path::glue($this->basePath(), 'VERSION');
                 if (file_exists($versionFile)) {
                     $this->version = trim(file_get_contents($versionFile));
                 }
                 if (!$this->version) {
                     throw new \RuntimeException('missing extension version');
                 }
             }
             return $this->version;
     }
 }
开发者ID:cepharum,项目名称:txf,代码行数:18,代码来源:extension.php

示例3: chdir

 * server or using requests including this script such as
 *
 *    <your-site>/run.php/appname/script.php
 *
 * which is then processing request for script "script.php" of application
 * "appname".
 *
 * @author Thomas Urban
 *
 */
try {
    include 'rewritten.php';
    // get application actually requested
    $application = txf::getContext()->application;
    // get script of application actually requested
    $script = path::glue($application->pathname, $application->script);
    // change to that folder for supporting homogenic use of relative pathnames
    chdir(dirname($script));
    // include selected script
    include_once $script;
    // due to disabled shutdown handler we are required to call related handler manually
    view::current()->onShutdown();
} catch (http_exception $e) {
    header($e->getResponse());
    view::variable('exception', $e);
    view::addBodyClass('exception');
    view::addBodyClass('http-exception');
    $data = variable_space::create('reason', $e);
    try {
        view::main(view::engine()->render('error/' . $e->getCode(), $data));
    } catch (\UnexpectedValueException $dummy) {
开发者ID:cepharum,项目名称:txf,代码行数:31,代码来源:run.php

示例4: scriptURL

 /**
  * Compiles URL addressing selected script of current application.
  *
  * @param string $scriptName pathname of script relative to application folder
  * @param array $parameters set of parameters to pass in query
  * @param mixed $selector first of multiple optional selectors to include
  * @return string URL of addressed script including optional parameters
  */
 public function scriptURL($scriptName, $parameters = array(), $selector = null)
 {
     if (!is_array($parameters)) {
         throw new \InvalidArgumentException('parameters must be array');
     }
     if (substr($scriptName, -4) == '.php') {
         $scriptName = substr($scriptName, 0, -4);
     }
     $selectors = func_get_args();
     $selectors = array_slice($selectors, 2);
     if (count($selectors) == 1 && is_array($selectors[0])) {
         $selectors = array_shift($selectors);
     }
     $selectors = implode('/', array_map(function ($selector) {
         return rawurlencode($selector);
     }, $selectors));
     switch (txf::getContextMode()) {
         case txf::CTXMODE_NORMAL:
         default:
             $url = path::glue($this->url, $scriptName, $selectors);
             break;
         case txf::CTXMODE_REWRITTEN:
             $proxy = $this->usedProxy === true ? '' : $this->usedProxy;
             if ($this->gotNameFromEnvironment) {
                 $url = path::glue($this->context->url, $proxy, $scriptName, $selectors);
             } else {
                 $url = path::glue($this->context->url, $proxy, $this->name, $scriptName, $selectors);
             }
             break;
     }
     return $url . (count($parameters) ? '?' . http_build_query($parameters) : '');
 }
开发者ID:cepharum,项目名称:txf,代码行数:40,代码来源:application.php

示例5: findResource

 /**
  * Looks for resource file selected by its relative pathname.
  *
  * This method is used to overload resources in framework by resources in
  * current application.
  *
  * @throws \InvalidArgumentException on providing empty or non-string pathname
  * @param string $resourcePathname relative pathname of resource to look for
  * @return string|null absolute pathname of found resource, null on mismatch
  */
 public function findResource($resourcePathname)
 {
     if (!is_string($resourcePathname) || ($resourcePathname = trim($resourcePathname)) === '') {
         throw new \InvalidArgumentException('invalid or missing resource pathname');
     }
     if ($this->context) {
         if ($this->context->application) {
             $pathname = path::glue($this->context->applicationPathname, $resourcePathname);
             if (is_dir($pathname)) {
                 return $pathname;
             }
         }
         $pathname = path::glue($this->context->frameworkPathname, $resourcePathname);
         if (is_dir($pathname)) {
             return $pathname;
         }
     }
     // no such extension
     return null;
 }
开发者ID:cepharum,项目名称:txf,代码行数:30,代码来源:txf.php

示例6: __construct

 public function __construct()
 {
     // include some initial assertions on current context providing minimum
     // set of expected information
     assert('$_SERVER["HTTP_HOST"]');
     assert('$_SERVER["DOCUMENT_ROOT"]');
     assert('$_SERVER["SCRIPT_FILENAME"]');
     /*
      * PHASE 1: Detect basic pathnames and URL components
      */
     $this->frameworkPathname = dirname(dirname(__FILE__));
     $this->installationPathname = dirname($this->frameworkPathname);
     $this->isHTTPS = $_SERVER['HTTPS'] != false || $_SERVER['HTTP_X_HTTPS'] != false;
     // analyse special case of working behind reverse proxy
     if (array_key_exists('HTTP_X_ORIGINAL_URL', $_SERVER)) {
         $url = parse_url($_SERVER['HTTP_X_ORIGINAL_URL']);
         $this->hostname = $url['host'];
         $proxyPrefix = $url['path'];
     } else {
         $proxyPrefix = false;
     }
     if (trim($this->hostname) === '') {
         $this->hostname = $_SERVER['HTTP_HOST'];
     }
     /*
      * PHASE 2: Validate and detect current application
      */
     // validate location of processing script ...
     // ... must be inside document root
     if (path::isInWebfolder($_SERVER['SCRIPT_FILENAME']) === false) {
         throw new \InvalidArgumentException('script is not part of webspace');
     }
     // ... must be inside installation folder of TXF
     $this->scriptPathname = path::relativeToAnother($this->installationPathname, realpath($_SERVER['SCRIPT_FILENAME']));
     if ($this->scriptPathname === false) {
         throw new \InvalidArgumentException('script is not part of TXF installation');
     }
     // derive URL's path prefix to select folder containing TXF installation
     $this->prefixPathname = path::relativeToAnother(realpath(static::getDocumentRoot()), $this->installationPathname);
     if ($this->prefixPathname === false) {
         // installation's folder might be linked into document root using symlink
         // --> comparing pathname of current script with document root will fail then
         //     --> try alternative method to find prefix pathname
         $this->prefixPathname = path::relativeToAnother(static::getDocumentRoot(), dirname($_SERVER['SCRIPT_FILENAME']));
     }
     // running behind reverse proxy?
     if ($proxyPrefix) {
         // detect prefix used to control that reverse proxy
         $request = implode('/', $this->getRequestedScriptUri($dummy));
         $split = strpos($proxyPrefix, $request);
         if ($split >= 0) {
             // extract prefix required by reverse proxy
             $proxyPrefix = substr($proxyPrefix, 0, $split);
             // prepend extracted prefix of reverse proxy to previously
             // detected prefix used to address installation of TXF locally
             $this->prefixPathname = path::glue($proxyPrefix, $this->prefixPathname);
         }
     }
     // cache some derivable names
     list($this->applicationPathname, $this->applicationScriptPathname) = path::stripCommonPrefix($this->scriptPathname, $this->prefixPathname, null);
     // compile base URL of current installation
     $this->url = path::glue(($this->isHTTPS ? 'https://' : 'http://') . $this->hostname, $this->prefixPathname);
     // detect current application
     $this->application = application::current($this);
 }
开发者ID:cepharum,项目名称:txf,代码行数:65,代码来源:context.php


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