Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function validate(SchemaDescriptor $a, SchemaDescriptor $b)
 {
     $diff = array_diff(array_keys($a->getMixins()), array_keys($b->getMixins()));
     if (count($diff)) {
         throw new ValidatorException(sprintf('The schema "%s" must include the following mixin(s): "%s".', $b, implode('", "', $diff)));
     }
 }
Esempio n. 2
0
 /**
  * @param SchemaDescriptor $schema
  *
  * @return array
  */
 private function getMixinSchemas(SchemaDescriptor $schema)
 {
     $schemaIds = [];
     foreach ($schema->getMixins() as $mixin) {
         $schemaIds[] = $mixin->getId()->getCurieWithMajorRev();
         $schemaIds = array_merge($schemaIds, $this->getExtendsSchemas($mixin), $this->getMixinSchemas($mixin));
     }
     return $schemaIds;
 }
 /**
  * {@inheritdoc}
  */
 public function validate(SchemaDescriptor $a, SchemaDescriptor $b)
 {
     foreach ($a->getMixins() as $mixin) {
         if ($m = $b->getMixin($mixin->getId()->getCurieWithMajorRev())) {
             if (!$m->isMixinSchema()) {
                 throw new ValidatorException(sprintf('The schema "%s" mixins can only include other mixins. The schema "%s" is not a mixin.', $b, $mixin->getId()->toString()));
             }
         }
     }
 }