コード例 #1
0
 public function getConfig($name)
 {
     $parts = explode('/', $name);
     $file = array_shift($parts);
     if (isset($this->configCache[$file])) {
         $c = $this->configCache[$file];
     } else {
         $cf = "{$this->configDir}/{$file}.json";
         if (!file_exists($cf)) {
             return null;
         }
         $c = EarthIT_JSON::decode(file_get_contents($cf), true);
         if ($c === null) {
             throw new Exception("Failed to load config from '{$cf}'");
         }
         $this->configCache[$file] = $c;
     }
     foreach ($parts as $p) {
         if (isset($c[$p])) {
             $c = $c[$p];
         } else {
             return null;
         }
     }
     return $c;
 }
コード例 #2
0
 public function dbExternalToSchemaValue($v, EarthIT_Schema_Field $f, EarthIT_Schema_ResourceClass $rc)
 {
     if ($v === null) {
         return null;
     } else {
         if (self::valuesOfTypeShouldBeSelectedAsGeoJson($f->getType()) or self::valuesOfTypeShouldBeSelectedAsJson($f->getType())) {
             return EarthIT_JSON::decode($v);
         } else {
             return $v;
         }
     }
 }
コード例 #3
0
 public function dbExternalToSchemaValue($v, EarthIT_Schema_Field $f, EarthIT_Schema_ResourceClass $rc)
 {
     if ($v === null) {
         return null;
     } else {
         if (self::valuesOfTypeShouldBeSelectedAsGeoJson($f->getType()) or self::valuesOfTypeShouldBeSelectedAsJson($f->getType())) {
             return EarthIT_JSON::decode($v);
         } else {
             if (($dataType = $f->getType()) && ($phpType = $dataType->getPhpTypeName()) !== null) {
                 return EarthIT_Storage_Util::cast($v, $phpType);
             } else {
                 return $v;
             }
         }
     }
 }