From b8901220c6a8dc0f8753d093eab8638b22e229ce Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Fri, 3 Dec 2010 00:45:44 +0100 Subject: [PATCH] prepared for metadata event --- backend/lib/Definition/Definition.php | 24 +++++++++++++++------ backend/lib/Definition/EntityDefinition.php | 3 ++- backend/lib/Interpreter/Interpreter.php | 2 -- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/backend/lib/Definition/Definition.php b/backend/lib/Definition/Definition.php index ec055da..f68672e 100644 --- a/backend/lib/Definition/Definition.php +++ b/backend/lib/Definition/Definition.php @@ -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]; } } -?> \ No newline at end of file +?> diff --git a/backend/lib/Definition/EntityDefinition.php b/backend/lib/Definition/EntityDefinition.php index 3f54eb9..49dbe43 100644 --- a/backend/lib/Definition/EntityDefinition.php +++ b/backend/lib/Definition/EntityDefinition.php @@ -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); } } -?> \ No newline at end of file +?> diff --git a/backend/lib/Interpreter/Interpreter.php b/backend/lib/Interpreter/Interpreter.php index 1eb0999..209d30a 100644 --- a/backend/lib/Interpreter/Interpreter.php +++ b/backend/lib/Interpreter/Interpreter.php @@ -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'); }