/**
  * @param $model
  * @return ValidationRule[]
  */
 public function getValidationRules($model) : array
 {
     $className = ClassHelper::getClassName($model);
     $validationRules = $this->store->get($className);
     if ($validationRules === null) {
         $validationRules = $this->createValidationRules($className);
         $this->store->set($className, $validationRules);
     }
     return $validationRules;
 }
Ejemplo n.º 2
0
 public function getMetadata($class) : ObjectMetadata
 {
     if (!is_a($class, MetadataAware::class, true)) {
         throw new \InvalidArgumentException('Invalid class. Accepted only MetadataAware instances');
     }
     /** @var MetadataAware|string $className */
     $className = ClassHelper::getClassName($class);
     // Resolving the container interface
     if ($this->container->contains($className)) {
         $className = $this->container->getClass($className);
     }
     if ($this->storage->contains($className)) {
         $metadata = $this->storage->get($className);
     } else {
         $metadata = $this->modelAnalyzer->analyze($className);
         $this->storage->set($className, $metadata);
     }
     return $metadata;
 }