コード例 #1
0
 public static function createBasedOnDescription($entityDescription)
 {
     $entity = new Entity();
     if (!array_key_exists('properties', $entityDescription)) {
         throw EntityFactoryException::descriptionMustContainsProperty();
     }
     foreach ($entityDescription['properties'] as $propertyName => $rules) {
         $entity->addProperty(PropertyFactory::create($propertyName, $rules));
     }
     return $entity;
 }
コード例 #2
0
 /**
  * Создать Property содержащее другие Property
  *
  * @param $propertyName
  * @param $definitions
  * @return CompositeProperty
  * @throws PropertyFactoryExceptions
  */
 protected static function createCompositeProperty($propertyName, $definitions)
 {
     if (!array_key_exists('properties', $definitions)) {
         throw PropertyFactoryExceptions::CompositePropertyMustContainsSubPropertiesDefinitions($propertyName, $definitions);
     }
     $property = new CompositeProperty($propertyName);
     foreach ($definitions['properties'] as $propertyName => $propertyDefinition) {
         $subProperty = PropertyFactory::create($propertyName, $propertyDefinition);
         $property->addProperty($subProperty);
     }
     return $property;
 }