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; }
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; } } }
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; } } } }
public function matches($item) { if (!array_key_exists($this->referenceName, $item)) { throw new Exception(__CLASS__ . '#' . __FUNCTION__ . " can't check item " . "because {$this->referenceName} isn't included on it: " . EarthIT_JSON::prettyEncode($item)); } if ($this->targetIsPlural) { $subItems = $item[$this->referenceName]; } else { $subItems = $item[$this->referenceName] === null ? array() : array($item[$this->referenceName]); } foreach ($subItems as $subItem) { if ($this->targetFilter->matches($subItem)) { return true; } } return false; }