Delete an entity object.

@param object $entity
@return \ProAI\Datamapper\Eloquent\Model
961445
protected function getEloquentModel($entity, $exists=false)
    {
        if (empty($entity)) {
            throw new Exception('Object transfered to EntityManager is empty');
        }

        if (! is_object($entity)) {
            throw new Exception('Object transfered to EntityManager is not an object');
        }

        $eloquentModel = Model::newFromDatamapperObject($entity);

        $eloquentModel->exists = $exists;

        return $eloquentModel;
    }
530860
public function delete($id)
    {
        $this->applyScope();

        $model = $this->find($id);
        $originalModel = clone $model;

        $this->resetModel();

        $deleted = $model->delete();

        event(new RepositoryEntityDeleted($this, $originalModel));

        return $deleted;
    }
796729
public function deleteObject($entity, $_id)
	{
		$retValue = true;
		$arrayWhere = array('_id' => $_id);

		if (! is_null($this->_conn)){
			$this->_conn->delete($entity, $arrayWhere);

			if ($this->error($this->_conn->error()))
				$retValue = false;
		}
		
		return $retValue;
	}
938818
public function delete($entity)
    {
        $event = new StorageEvent($entity);
        $this->event()->dispatch(StorageEvents::PRE_DELETE, $event);
        $qb = $this->em->createQueryBuilder()
            ->delete($this->getTableName())
            ->where('id = :id')
            ->setParameter('id', $entity->getId());

        $response = $qb->execute();
        $event = new StorageEvent($entity);
        $this->event()->dispatch(StorageEvents::POST_DELETE, $event);

        return $response;
    }
99052
public function deleteEntityById($entity, $id)
    {
        $tbl = $this->_resource->getTableName($entity);
        $where = [];
        foreach ($id as $field => $value) {
            $where["`$field`=?"] = $value;
        }
        $result = $this->_conn->delete($tbl, $where);
        return $result;
    }
129473
public function deleteEntity($entity)
    {
        if (!$this->isExtendedField($entity)) {
            return parent::deleteEntity($entity);
        }

        // Pre-delete event (same as core).
        $id    = $entity->getId();
        $event = $this->dispatchEvent('pre_delete', $entity);
        $this->getRepository()->deleteEntity($entity);

        $schema        = $this->getSchemaDefinition($entity->getName(), $entity->getType());
        $secure        = 'extendedFieldSecure' === $entity->getObject() ? '_secure' : '';
        $extendedTable = MAUTIC_TABLE_PREFIX.'lead_fields_leads_'.$schema['type'].$secure.'_xref';
        $column        = [
            'lead_field_id' => $entity->getId(),
        ];
        $this->em->getConnection()->delete(
            $extendedTable,
            $column
        );

        // Post-delete event (same as core).
        // set the id for use in events
        $entity->deletedId = $id;
        $this->dispatchEvent('post_delete', $entity, false, $event);
    }
572936
public function deleteOne(FlexibleEntityInterface &$entity)
    {
        $entity = $this->deleteByPK($entity->fields($this->getStructure()->getPrimaryKey()));

        return $this;
    }
1047850
public function removeEntity($entity)
    {
        $registries = $this->findRegistriesEntityById(get_class($entity), $entity->getObjectIdentifier());

        foreach ($registries as $registry) {
            $this->remove($registry);
        }
    }
959701
public function deleteObject($entity, $_id)
	{
		$retValue = false;

		try{
			$query = array('_id' => new MongoId($_id));

			if (! is_null($this->_db)){
				$mongo = $this->_db->selectCollection($entity);

			    // Remove Object
				$result = $mongo->remove($query, array('w' => 1));
				
				if ($result["n"] > 0)
					$retValue = true;
			}
		}
		catch (Exception $e) {
			$this->_log->addError($e->getMessage());
		    $retValue = false;
		}

		return $retValue;
	}
266500
public function delete($entity) {
		if (is_null($entity))
			return;
		
		//connect to database
		$this->mapper->connect();
		
		//begin transaction
		$this->mapper->beginTransaction();
		
		//get primary key
		$pk = $this->getPropertyValue($this->entityProfile, $entity, $this->entityProfile->getPrimaryKey());

		foreach ($this->entityProfile->getReferences() as $assoc)
			$this->entityProfile->getAssociation($assoc)->delete($this->mapper, $pk);
		
		//build fluent query
		$query = $this->mapper->newQuery()
		->deleteFrom($this->entityProfile->getEntityTable())
		->where(Column::__callstatic($this->entityProfile->getPrimaryKey(true))->eq($pk));
		
		//run query
		$result = $query->exec();
		
		//commit
		$this->mapper->commit();
		return $result;
	}
54643
public function delete($entity, $flush = true)
    {
        $this->getEntityManager()->remove($entity);

        if ($flush) {
            $this->getEntityManager()->flush();
        }
        return $this;
    }
239496
protected function _deleteFromTree($entity) {
		extract($this->_config);

		$span = 1;
		if ($entity->$right - $entity->$left !== 1) {
			$span = $entity->$right - $entity->$left;
			$model::remove([$parent => $entity->data($model::key())]);
		}
		$this->_update($entity->$right, '-', $span + 1, $this->_scope($entity));
		return true;
	}
977572
public function delete()
    {
        if (!$this->hasId()) {
            throw new DeleteException('ID not set - did you call find($id) before delete()?');
        }

        if (!$this->isDeletable()) {
            throw new DeleteException('Permission denied: Entity can not be deleted');
        }

        $this->transactional(function () {
            $this->forceDelete();
        });

        return $this;
    }
558707
protected function findAndRemove(EntityInterface $entity = null)
    {
        if (null == $entity) {
            return $entity;
        }

        /** @var EntityInterface $existent */
        foreach ($this->data as $key => $existent) {
            if ($existent->getId() == $entity->getId()) {
                parent::remove($key);
                $this->getEmitter()
                    ->emit(
                        new EntityRemoved(
                            $entity,
                            ['collection' => $this]
                        )
                    );
                break;
            }
        }
        
        return $entity;
    }
232292
public function delete(Entity $entity)
    {
        $this->delete = new Delete('history');
        $this->delete->where(array(
             'history.history_id = ?' => $entity->getHistoryId()
        ));
                 
        return $this->deleteRow();
    }
1136751
public function delete(EntityInterface $entity)
    {
        return $this->infakt->delete($this->getServiceName().'/'.$entity->getId().'.json');
    }
24512
public function handle(Entity $entity)
    {
        // We will initially check if the model is using soft deletes. If so,
        // the attribute values will remain untouched as they should sill
        // be available till the entity is truly deleted from database.
        if (in_array(SoftDeletes::class, class_uses_recursive(get_class($entity))) && ! $entity->isForceDeleting()) {
            return;
        }

        foreach ($entity->getEntityAttributes() as $attribute) {
            if ($entity->relationLoaded($relation = $attribute->getAttribute('slug'))
                && ($values = $entity->getRelationValue($relation)) && ! $values->isEmpty()) {
                // Calling the `destroy` method from the given $type model class name
                // will finally delete the records from database if any was found.
                // We'll just provide an array containing the ids to be deleted.
                forward_static_call_array([$attribute->getAttribute('type'), 'destroy'], [$values->pluck('id')->toArray()]);
            }
        }
    }