コード例 #1
0
 public function getPath()
 {
     $dir = $this->config['path'];
     if (FajrUtils::isAbsolutePath($dir)) {
         return $dir;
     }
     // default resolve relative to Template.Directory
     $relativeTo = FajrConfig::getDirectory('Template.Directory');
     return FajrUtils::joinPath($relativeTo, $dir);
 }
コード例 #2
0
 public function testIsAbsolutePath()
 {
     $this->assertTrue(FajrUtils::isAbsolutePath('/'), 'Unix filesystem root is absolute');
     $this->assertTrue(FajrUtils::isAbsolutePath('/foo'), '/foo is absolute');
     $this->assertTrue(FajrUtils::isAbsolutePath('/foo/bar/'), '/foo/bar is absolute');
     $this->assertTrue(FajrUtils::isAbsolutePath('C:\\'), 'C:\\ is absolute');
     $this->assertTrue(FajrUtils::isAbsolutePath('\\\\servername\\folder'), '\\\\servername\\folder UNC path is absolute');
     $this->assertFalse(FajrUtils::isAbsolutePath('foo'), 'foo is relative');
     $this->assertFalse(FajrUtils::isAbsolutePath('./'), './ is relative');
 }
コード例 #3
0
 /**
  * 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::$defaultOptions
  * @see FajrConfig::$directoriesRelativeTo
  * @see configuration.example.php
  */
 public static function getDirectory($key)
 {
     self::assertInitialized();
     $dir = self::get($key);
     if ($dir === null) {
         return null;
     }
     if (FajrUtils::isAbsolutePath($dir)) {
         return $dir;
     }
     // default resolve relative
     $relativeTo = FajrUtils::joinPath(dirname(__FILE__), '..');
     $parameters = self::getParameterDescription();
     assert(array_key_exists($key, $parameters));
     $param = $parameters[$key];
     if (array_key_exists('relativeTo', $param)) {
         $relativeTo = self::getDirectory($param['relativeTo']);
     }
     return FajrUtils::joinPath($relativeTo, $dir);
 }
コード例 #4
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);
 }