/** * Deletes the persistent $object. * * This method will perform a DELETE query based on the identifier of the * persistent $object. After delete() the ID property of $object will be * reset to null. It is possible to {@link save()} $object afterwards. * $object will then be stored with a new ID. * * If you defined relations for the given object, these will be checked to * be defined as cascading. If cascading is configured, the related objects * with this relation will be deleted, too. * * The object will also be removed from the identity map and all related * object sets in it. * * Relations that support cascading are: * <ul> * <li>{@link ezcPersistenOneToManyRelation}</li> * <li>{@link ezcPersistenOneToOne}</li> * </ul> * * @throws ezcPersistentDefinitionNotFoundxception * if $the object is not recognized as a persistent object. * @throws ezcPersistentObjectNotPersistentException * if the object is not persistent already. * @throws ezcPersistentQueryException * if the object could not be deleted. * * @param ezcPersistentObject $object The persistent object to delete. */ public function delete($object) { $this->session->delete($object); $class = get_class($object); $def = $this->session->definitionManager->fetchDefinition($class); $state = $object->getState(); $id = $state[$def->idProperty->propertyName]; $this->identityMap->removeIdentity($class, $id); }