/** * (non-PHPdoc) * @see Atrox/Core/Data/Atrox_Core_Data_Source#delete() */ public function delete(Atrox_Core_Data_Entity $entity) { if (!is_numeric($id = $entity->getId())) { throw new Exception("Non-integer ID passed to delete: " . $entity->getId()); return false; } if (!$entity->beforeDelete()) { throw new Exception("beforeDelete failed"); return false; } $result = $this->quickDelete($id); if ($this->connection->getAffectedCount($result) != 1) { return false; } $this->serviceLocator->getCacheManager()->clear($this->getCacheKey($this->idName . ":" . $id)); foreach ($this->properties as $name => $property) { if ($property->getType() == Atrox_Core_Data_Property::TYPE_BINARY) { $this->deleteBinary($entity->get($name)); } } if (!$entity->afterDelete()) { throw new Exception("afterDelete failed"); return false; } return true; }
/** * * @see Atrox_Core_Data_Source#validate() */ public function validate(Atrox_Core_Data_Entity $entity) { $valid = true; foreach ($this->properties as $name => $property) { $valid = $property->validate($entity->get($name)) && $valid; } return $valid; }