Esempio n. 1
0
 /**
  *
  * @see Core/Data/Atrox_Core_Data_IValidator#validate($value)
  */
 public function validate($value, Atrox_Core_Data_Property $property)
 {
     $dataSource = $property->getDataSource();
     $filter = $property->getDataSource()->makeFilter();
     $filter->addConditional($dataSource->getTableName(), $property->getName(), $value);
     $count = $dataSource->count($filter);
     return $count <= 1 ? true : "'" . $property->getDescription() . "' must be unique. '{$value}' is already used";
 }
Esempio n. 2
0
 /**
  * Called in setup to define the shape of this entity.
  *
  * @see setup
  *
  * @throws Atrox_Core_Data_Exception_DuplicatePropertyException If this entity already has the property
  *
  * @param Atrox_Core_Data_Property $property
  *
  * @return Atrox_Core_Data_Property
  */
 public function addProperty(Atrox_Core_Data_Property $property)
 {
     $propertyName = $property->getName();
     if (isset($this->properties[$propertyName])) {
         throw new Atrox_Core_Data_Exception_DuplicatePropertyException("'{$propertyName}' is already defined for this Entity");
     }
     $this->properties[$propertyName] = $property;
     return $property;
 }
Esempio n. 3
0
 /**
  *
  * @param Atrox_Core_Data_Property $property
  * @return string
  */
 public function parseProperty(Atrox_Core_Data_Property $property)
 {
     return $this->parseTable($property->getDataSource()->getTableName()) . "." . $this->parseField($property->getName());
 }