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


PHP Conf::instance方法代码示例

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


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

示例1: Conf

 /**
  * This implements the 'singleton' design pattern
  *
  * @return Conf The one and only instance
  */
 static function get_instance()
 {
     if (!self::$instance) {
         self::$instance = new Conf();
     }
     return self::$instance;
 }
开发者ID:astephanh,项目名称:kolab-autoconf,代码行数:12,代码来源:Conf.php

示例2: buildNavigation

 public function buildNavigation($path)
 {
     //var_dump($path);
     //http://localhost/bong/index.php/controllerName/methodName/arg1/arg2/+spiritName/methodName/spiritArg1/spiritArg2/+spiritName2/methodName/args
     $this->navigation->controllerName = null;
     $this->navigation->methodName = null;
     $this->navigation->args = array();
     $this->navigation->spirits = array();
     $racks = array();
     foreach ($path as $i => $urlSection) {
         if (strlen($urlSection) > 0 && $urlSection[0] == '+') {
             $racks[] = array();
         }
         $racks[count($racks) == 0 ? count($racks) : count($racks) - 1][] = $urlSection;
     }
     foreach ($racks as $i => &$rack) {
         if ($i == 0) {
             $this->navigation->controllerName = isset($rack[0]) && !empty($rack[0]) ? $rack[0] : Conf::instance()->evaluate('default.controller');
             $this->navigation->methodName = isset($rack[1]) && !empty($rack[1]) ? $rack[1] : Conf::instance()->evaluate('default.method');
             for ($i = 2; $i < count($rack); ++$i) {
                 $this->navigation->args[] = $rack[$i];
             }
         } else {
             if (count($rack) > 1) {
                 //Ignore if no MethodName is provided
                 $spirit = new stdClass();
                 $spirit->spiritName = substr($rack[0], 1);
                 //remove the + sign
                 $spirit->methodName = $rack[1];
                 $spirit->args = array();
                 for ($i = 2; $i < count($rack); ++$i) {
                     $spirit->args[] = $rack[$i];
                 }
                 $this->navigation->spirits[] = $spirit;
             }
         }
     }
     if (is_null($this->navigation->controllerName)) {
         $this->navigation->controllerName = 'default';
     }
     if (is_null($this->navigation->methodName)) {
         $this->navigation->methodName = 'main';
     }
     MemPool::instance()->set('bong.mvc.controller', $this->navigation->controllerName);
     MemPool::instance()->set('bong.mvc.method', $this->navigation->methodName);
     Runtime::loadModule('mvc');
     //print_r($this->navigation);
 }
开发者ID:neel,项目名称:bong,代码行数:48,代码来源:mvcrouter.php

示例3: decide

 /**
  * Returns a Suitable ContentRouter Object based upon the URL Pattern
  * The Caller needs to extract the engine from the Router through the appropiate Getter
  * the Validate the Engine then Run the Engine
  * $engine = $router->engine();
  * $engine->check(); or $engine->validate();
  * $engine->run();
  */
 public function decide()
 {
     $projectName = null;
     // issue #31 https://github.com/neel/bong/issues/31
     $urlparts = strlen(trim($this->url, "/")) ? explode('/', trim($this->url, "/")) : array();
     //Slash The Url
     $reqUrlParts = explode('/', trim($_SERVER['REQUEST_URI'], "/"));
     $urlroot = '/' . implode('/', array_slice($reqUrlParts, 0, count($reqUrlParts) - count($urlparts)));
     MemPool::instance()->set("bong.url.root", $urlroot);
     /**
      * URL with Default Project:
      * controllername
      * controllername/methodname
      * controllerName.extension/methodName
      * image.png
      * The Extension could be anything like dbg, mc, static, sync etc..
      * 
      * URL with default / non default Project Name
      * ~projectName/controllername
      * ~projectName/controllername/methodname
      * ~projectName/controllerName.extension/methodName
      * ~projectName/image.png
      */
     $projectExt = null;
     if (count($urlparts) && substr_count($urlparts[0], '~') == 1) {
         $projectName = substr(array_shift($urlparts), 1);
         if (substr_count($projectName, '.') == 1) {
             $parts = explode('.', $projectName);
             $projectName = $parts[0];
             $projectExt = $parts[1];
         }
     } elseif (count($urlparts) && substr_count($urlparts[0], '~') > 1) {
         throw new MalformedUrlException();
     } else {
         $projectName = Fstab::instance()->defaultProjectName();
     }
     if (Fstab::instance()->projectExists($projectName)) {
         $projectLocation = Fstab::instance()->projectLocation($projectName);
         if ($projectLocation && is_dir($projectLocation)) {
             if (is_readable($projectLocation)) {
                 MemPool::instance()->set("bong.project.current", $projectName);
                 Runtime::setCurrentProject($projectName);
             } else {
                 throw new ProjectDirNotReadableException($projectName . '');
             }
         } else {
             throw new ProjectDirNotFoundException($projectName . '');
         }
     } else {
         throw new ProjectNotFoundException($projectName . '');
     }
     $urlbase = '/' . implode('/', array_slice($reqUrlParts, 0, count($reqUrlParts) - count($urlparts)));
     MemPool::instance()->set("bong.url.base", $urlbase);
     $urlExtracted = '/' . implode('/', $urlparts);
     //{ Start FSM Handling
     /**
      * Now if invoked /~project.fsm
      * load the fsm display
      */
     if ($projectExt == 'fsm') {
         return RouterFactory::produce('FSMRouter');
     }
     //} end FSM Handling
     $patterns = array('resource.local' => Conf::instance()->evaluate('urlpatterns.resource.local'), 'resource.sys' => Conf::instance()->evaluate('urlpatterns.resource.sys'), 'service.app' => Conf::instance()->evaluate('urlpatterns.service.app'), 'service.spirit' => Conf::instance()->evaluate('urlpatterns.service.spirit'));
     $type = 'mvc';
     //var_dump($urlExtracted);
     foreach ($patterns as $key => $pattern) {
         //echo ">> {$urlExtracted} => $pattern\n";
         assert('!empty($pattern)' . "/*{$key} => {$pattern}*/");
         if (preg_match($pattern, $urlExtracted, $m)) {
             //echo ">>\tMatched!\n";
             $type = $key;
             break;
         }
     }
     MemPool::instance()->set("bong.router.pattern", $type);
     /* AbstractContentRouter*  */
     $router = null;
     switch ($type) {
         case 'resource.local':
         case 'resource.sys':
             $router = RouterFactory::produce('ResourceRouter');
             break;
         case 'service.app':
             $router = RouterFactory::produce('AppServiceRouter');
             break;
         case 'service.spirit':
             $router = RouterFactory::produce('SpiritServiceRouter');
             break;
         case 'mvc':
             $router = RouterFactory::produce('MVCRouter');
             break;
//.........这里部分代码省略.........
开发者ID:neel,项目名称:bong,代码行数:101,代码来源:urlanalyzer.php

示例4: print_r

/**
 * Slash the Url to Get URL Parts.
 * e.g. exploding it with '/' will extract all URL Parts in an array
 */
MemPool::instance()->set("bong.url.path", $_SERVER['PATH_INFO']);
/**
 * \required instances
 * Fstab		Project details
 * Path			Path details
 * Conf			Configuration details
 * URLAnalyzer	URL details
 */
$fstab = Fstab::instance();
print_r($fstab->defaultProjectName());
echo PHP_EOL;
print_r($fstab->defaultProject());
print_r($fstab->projectNames());
print_r($fstab->projects());
print_r($fstab->projectExists("bong"));
echo PHP_EOL;
print_r($fstab->projectLocation("main"));
echo PHP_EOL;
var_dump($fstab->project("main")->exists());
echo "\n--------------------------\n";
$path = Path::instance();
var_dump($path->evaluate("etc.conf"));
var_dump($path->evaluate(":mkt"));
var_dump($path->evaluate("project:mkt"));
var_dump($path->evaluate(":mkt.etc.conf"));
$conf = Conf::instance();
var_dump($conf->evaluate("urlpatterns.sync"));
开发者ID:neel,项目名称:bong,代码行数:31,代码来源:test0.php


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