Beispiel #1
0
 /**
  * This method returns the JSON schema for the specified input.
  *
  * @access public
  * @static
  * @param mixed $schema                                     the JSON schema to be loaded
  * @return array                                            the JSON schema
  */
 public static function resolveJSONSchema($schema)
 {
     if (is_string($schema)) {
         $components = preg_split('/(\\\\|_)+/', trim($schema, '\\'));
         $file = Bootstrap::rootPath() . implode(DIRECTORY_SEPARATOR, $components) . '.json';
         $schema = Config\JSON\Reader::load(new IO\File($file))->read();
     }
     $schema = Core\Convert::toDictionary($schema);
     if (isset($schema['$ref'])) {
         $result = MappingService\Data\Model\JSON\Helper::resolveJSONSchema($schema['$ref']);
         if (isset($schema['properties'])) {
             $result = array_merge($result, $schema['properties']);
         }
         return $result;
     }
     return $schema;
 }
Beispiel #2
0
 /**
  * This constructor initializes the class.
  *
  * @access public
  * @param mixed $schema                                     the JSON schema
  * @param boolean $case_sensitive                           whether field names are case
  *                                                          sensitive
  */
 public function __construct($schema, $case_sensitive = true)
 {
     parent::__construct();
     $this->schema = MappingService\Data\Model\JSON\Helper::resolveJSONSchema($schema);
     $this->case_sensitive = Core\Convert::toBoolean($case_sensitive);
 }