Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
 /**
  * This constructor initializes the class with the specified URI.
  *
  * @access public
  * @param string $uri                                       the URI to the file
  * @throws Throwable\InvalidArgument\Exception              indicates a data type mismatch
  */
 public function __construct($uri)
 {
     $this->name = null;
     $this->path = null;
     $this->ext = null;
     if (!Common\String::isTypeOf($uri)) {
         throw new Throwable\InvalidArgument\Exception('Unable to handle argument. Argument must be a string, but got :type.', array(':type' => gettype($uri)));
     }
     $this->uri = preg_replace('/^classpath:/i', Bootstrap::rootPath(), $uri, 1);
     $this->temporary = false;
 }