Пример #1
0
 /**
  * Setups up the properties for this entity.
  *
  * @return null
  */
 public static function getSchema()
 {
     static $schema;
     if (!$schema) {
         $schema = new Atrox_Core_Data_EntitySchema();
         $schema->addProperty(new Atrox_Core_Data_Property_Integer("id"));
         $schema->addProperty(new Atrox_Core_Data_Property_String("firstName"));
         $schema->addProperty(new Atrox_Core_Data_Property_String("lastName"));
         $schema->addProperty(new Atrox_Core_Data_Property_String("mobile"));
         $schema->addProperty(new Atrox_Core_Data_Property_String("description"));
         $schema->addProperty(new Atrox_Core_Data_Property_Email("email"));
         $schema->addProperty(new Atrox_Core_Data_Property_Date("dateCreated"));
     }
     return $schema;
 }
Пример #2
0
 /**
  * Validates this entity and returns an array of errors.
  *
  * @return array A list of errors or an empty array if there have been no errors.
  */
 function validate()
 {
     $errors = array();
     $properties = $this->schema->getProperties();
     foreach ($properties as $name => $property) {
         $response = $property->validate($this->{$name});
         if (count($response) > 0) {
             if (!isset($errors[$name])) {
                 $errors[$name] = array();
             }
             $errors[$name][] = $response;
         }
     }
     return $errors;
 }