Exemplo n.º 1
0
 /**
  * @param \Yosmanyga\Resource\Resource $resource
  *
  * @return \Yosmanyga\Validation\Validator\ObjectValidator[]
  */
 public function load($resource)
 {
     if ($this->cacher->check($resource)) {
         return $this->cacher->retrieve($resource);
     }
     $this->reader->open($resource);
     /** @var \Yosmanyga\Validation\Resource\Definition\ObjectDefinition[] $definitions */
     $definitions = array();
     /** @var \Yosmanyga\Validation\Validator\ObjectValidator[] $validators */
     $validators = array();
     while ($data = $this->reader->current()) {
         /** @var \Yosmanyga\Validation\Resource\Definition\ObjectDefinition $definition */
         $definition = $this->normalizer->normalize($data, $resource);
         $definitions[$definition->class] = $definition;
         $validators[$definition->class] = $this->compiler->compile($definition);
         $this->reader->next();
     }
     $validators = $this->fillObjectValidators($definitions, $validators);
     $this->cacher->store($validators, $resource);
     return $validators;
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function close()
 {
     $this->reader->close();
     unset($this->readers);
     unset($this->reader);
 }