コード例 #1
0
ファイル: Router.php プロジェクト: BGCX067/fajr-git
 /** Return an instance of Router
  * @return Router
  */
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         $config = FajrConfigLoader::getConfiguration();
         $cachePath = $config->getDirectory(FajrConfigOptions::PATH_TO_ROUTER_CACHE);
         $controllerPath = FajrUtils::joinPath(FajrUtils::getProjectRootDirectory(), '/src/controller');
         $locator = new FileLocator(array($controllerPath));
         $request = SymfonyRequest::createFromGlobals();
         $requestContext = new RequestContext();
         $requestContext->fromRequest($request);
         $sfRouter = new SymfonyRouter(new YamlFileLoader($locator), "routes.yml", array('cache_dir' => $config->get(FajrConfigOptions::USE_CACHE) ? $cachePath : null), $requestContext);
         self::$instance = new Router($sfRouter, $request);
     }
     return self::$instance;
 }
コード例 #2
0
 /**
  * @returns string absolute path to configuration file
  */
 public static function getConfigurationFileName()
 {
     return FajrUtils::joinPath(FajrUtils::getProjectRootDirectory(), '/config/configuration.php');
 }
コード例 #3
0
ファイル: FajrConfig.php プロジェクト: BGCX067/fajr-git
 /**
  * Get a directory configuration path.
  *
  * If a relative path is given in configuration, it is resolved
  * relative to the specified directory or project root directory
  * if no directory was specified
  *
  * @param string $key
  * @returns string absolute path for the directory specified in configuration
  *                 or null if this option was not specified and does not have
  *                 a default value
  * @see FajrConfig::getParameterDescription()
  * @see configuration.example.php
  */
 public function getDirectory($key)
 {
     $dir = $this->get($key);
     if ($dir === null) {
         return null;
     }
     if (FajrUtils::isAbsolutePath($dir)) {
         return $dir;
     }
     // default resolve relative
     $relativeTo = FajrUtils::getProjectRootDirectory();
     $parameters = $this->getParameterDescription();
     assert(array_key_exists($key, $parameters));
     $param = $parameters[$key];
     if (array_key_exists('relativeTo', $param)) {
         $relativeTo = $this->getDirectory($param['relativeTo']);
     }
     return FajrUtils::joinPath($relativeTo, $dir);
 }