示例#1
0
 function init(&$args)
 {
     Args::label($args, 'schema_file');
     /* load the raw schema data */
     $this->_schema_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . Schema::SCHEMA_FILE;
     if (isset($args->schema_file) === true) {
         /* first param, if present, overrides schema file */
         $this->_schema_file = $args->schema_file;
     }
     $this->_schema = JSON::decode_file($this->_schema_file);
     if ($this->_schema === NULL) {
         if (file_exists($this->_schema_file) === true) {
             /* schema file exists but isn't loading - probably a stray comma */
             throw new ConfigException('fatal; unable to parse schema file: ' . $this->_schema_file);
         } else {
             /* sschema doesn't exist */
             throw new ConfigException('fatal; schema file: ' . $this->_schema_file . ', doesn\'t exist');
         }
     }
 }
示例#2
0
 function init(&$args)
 {
     Args::label($args, 'model_file');
     /* load the raw model data */
     $this->_model_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . Backend::MODEL_FILE;
     if (isset($args->model_file) === true) {
         /* first param, if present, overrides model name */
         $this->_model_file = $args->model_file;
     }
     $this->_model = JSON::decode_file($this->_model_file);
     if ($this->_model === NULL) {
         if (file_exists($this->_model_file) === true) {
             /* model file exists but isn't loading - probably a stray comma */
             throw new ConfigException('fatal; unable to parse model file: ' . $this->_schema_file);
         } else {
             /* file doesn't exist, create it with '{}' */
             file_put_contents($this->_model_file, '{}');
             $this->_model = JSON::decode_file($this->_model_file);
         }
     }
 }