prepared for metadata event
This commit is contained in:
parent
8ff55be33a
commit
b8901220c6
3 changed files with 20 additions and 9 deletions
|
@ -61,18 +61,22 @@ abstract class Definition {
|
|||
* Factory method for creating new instances
|
||||
*
|
||||
* @param string $name
|
||||
* @return Util\Definition
|
||||
* @return Util\Definition|array
|
||||
*/
|
||||
public static function get($name) {
|
||||
public static function get($name = NULL) {
|
||||
if (is_null(static::$definitions)) {
|
||||
static::load();
|
||||
}
|
||||
|
||||
if (!static::exists($name)) {
|
||||
if (is_null($name)) {
|
||||
return static::$definitions;
|
||||
}
|
||||
elseif (static::exists($name)) {
|
||||
return static::$definitions[$name];
|
||||
}
|
||||
else
|
||||
throw new \Exception('Unknown definition');
|
||||
}
|
||||
|
||||
return static::$definitions[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,6 +93,8 @@ abstract class Definition {
|
|||
|
||||
/**
|
||||
* Load JSON definitions from file (via lazy loading from get())
|
||||
*
|
||||
* @todo add caching
|
||||
*/
|
||||
protected static function load() {
|
||||
static::$definitions = array();
|
||||
|
@ -101,6 +107,12 @@ abstract class Definition {
|
|||
public static function getJSON() {
|
||||
return Util\JSON::decode(file_get_contents(VZ_BACKEND_DIR . static::FILE));
|
||||
}
|
||||
|
||||
/*
|
||||
* Setter & Getter
|
||||
*/
|
||||
public function getName() { return $this->name; }
|
||||
public function getTranslation($language) { return $this->translation[$language]; }
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -87,9 +87,10 @@ class EntityDefinition extends Definition {
|
|||
* Setter & Getter
|
||||
*/
|
||||
public function getInterpreter() { return $this->interpreter; }
|
||||
public function getModel() { return $this->model; }
|
||||
public function getUnit() { return $this->unit; }
|
||||
public function getRequiredProperties() { return $this->required; }
|
||||
public function getValidProperties() { return array_merge($this->required, $this->optional); }
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -63,8 +63,6 @@ abstract class Interpreter implements InterpreterInterface {
|
|||
$this->from = (isset($from)) ? self::parseDateTimeString($from, time() * 1000) : NULL;
|
||||
$this->to = (isset($to)) ? self::parseDateTimeString($to, (isset($this->from)) ? $this->from : time() * 1000) : NULL;
|
||||
|
||||
Util\Debug::log('time', $this->from, $this->to);
|
||||
|
||||
if (isset($this->from) && isset($this->to) && $this->from > $this->to) {
|
||||
throw new \Exception('&from is larger than &to parameter');
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue