/** * Deletes an entity and all respective meta properties (through database foreign keys). * * @param AbstractEntity|int $entity * @return int * @throws InvalidArgumentException */ public function delete($entity) { if ($entity instanceof AbstractEntity) { $eid = $entity->need($entity->getPrimary()); } else { $eid = $entity; } if (!(is_numeric($eid) && $eid > 0)) { throw new InvalidArgumentException('Entity id must be numeric'); } $entity = $this->get($eid); $id = $entity->getPrimary(); $deletion = $this->entityTable->delete(array($id => $eid)); $this->getEventManager()->trigger('delete', $entity); return $deletion; }