Remove and flush a given entity

@param $entity

@param string $entityManager
183437
public function deleteAndFlush($entity, $entityManager = null)
    {
        $entityManager = $this->getEntityManager($entityManager);

        $entityManager->remove($entity);
        $entityManager->flush($entity);
    }
427746
public function save($entity)
    {
        $this
            ->objectManager
            ->persist($entity);

        $this
            ->objectManager
            ->flush($entity);
    }
741780
public static function delete(string $entity, $data, bool $checkPermission = true)
    {
        self::exeDelete($entity, $data, $checkPermission);
    }
371586
public function deleteEntity(\Dlin\Saasu\Entity\EntityBase $entity)
    {
        $this->throttler->throttle();
        $uid = $entity->uid;
        if (intval($uid) > 0) { //load data from remote service
            $url = $this->_buildURL($entity->getName(), array('uid' => $uid));

            $response = $this->client->delete($url)->send();

            //check exception in response
            $this->checkException($response);
        }
        return $this;

    }
715776
public function delete($entity)
    {
        $this->gateway->delete($this->tableName, $this->builder->reduce($entity), $this->getIdentifier($entity));
    }
1143165
public function handle(Entity $entity): void
    {
        $this->trash = $entity->getEntityAttributeValueTrash();

        // Wrap the whole process inside database transaction
        $connection = $entity->getConnection();
        $connection->beginTransaction();

        try {
            foreach ($entity->getEntityAttributes() as $attribute) {
                if ($entity->relationLoaded($relation = $attribute->getAttribute('slug'))) {
                    $relationValue = $entity->getRelationValue($relation);

                    if ($relationValue instanceof ValueCollection) {
                        foreach ($relationValue as $value) {
                            // Set attribute value's entity_id since it's always null,
                            // because when RelationBuilder::build is called very early
                            $value->setAttribute('entity_id', $entity->getKey());
                            $this->saveOrTrashValue($value);
                        }
                    } elseif (! is_null($relationValue)) {
                        // Set attribute value's entity_id since it's always null,
                        // because when RelationBuilder::build is called very early
                        $relationValue->setAttribute('entity_id', $entity->getKey());
                        $this->saveOrTrashValue($relationValue);
                    }
                }
            }

            if ($this->trash->count()) {
                // Fetch the first item's class to know the model used for deletion
                $class = get_class($this->trash->first());

                // Let's batch delete all the values based on their ids
                $class::whereIn('id', $this->trash->pluck('id'))->delete();

                // Now, empty the trash
                $this->trash = collect([]);
            }
        } catch (Exception $e) {
            // Rollback transaction on failure
            $connection->rollBack();

            throw $e;
        }

        // Commit transaction on success
        $connection->commit();
    }
1101175
public function free(EntityNodeInterface $entity)
	{
		$this->repository->free($entity);
		$this->repository = null;
	}
530216
public function clear($entity)
    {
        /**
         * @var ObjectManager $objectManager
         */
        $objectManager = $this
            ->get('elcodi.provider.manager')
            ->getManagerByEntityNamespace(get_class($entity));

        $objectManager->clear($entity);

        return $this;
    }
227406
public function deleteAllRelations($entity)
    {
        $this->deleteNotes($entity);
        $this->deleteAddresses($entity);
        $this->deleteEmails($entity);
        $this->deleteFaxes($entity);
        $this->deleteSocialMediaProfiles($entity);
        $this->deletePhones($entity);
        $this->deleteUrls($entity);
    }
1130711
public function remove($entity)
    {
        //Get meta information
        $meta = $this->getMeta($entity);

        //Get a hash of this entity
        $hash = $this->getHash($entity);

        if($meta instanceof NodeMeta)
        {
            $this->nodeEntitiesToRemove[$hash] = $entity;
        }

        else
        {
            $this->relationEntitiesToRemove[$hash] = $entity;
        }
    }
749466
public function deleteEntity(EntityInterface $entity)
    {
        $delete = $this->tableGateway->getSql()->delete();
        $delete->where->equalTo(
            $this->tableGateway->getPrimaryKey(), $entity->getIdentifier()
        );

        try {
            $this->tableGateway->deleteWith($delete);
        } catch (RuntimeException $e) {
            return false;
        }

        return true;
    }
1168383
public function delete(Entity $entity)
    {
        $endPointUrl = $this->getEndPointUrl(get_class($entity));

        if (method_exists($entity, 'endPointUrlArg')) {
            $endPointUrl.= '/'.$entity->endPointUrlArg();
        }

        return $this->curlDelete($endPointUrl);
    }
79336
public static function update($entity)
    {
        $entityManager = self::getEntityManager();
        $entity = $entityManager->merge($entity);
        $entityManager->flush(); // transact

        return $entity;
    }
478894
protected function deleteEntity($entity)
    {
        $this->checkEntityType($entity);

        $delete = new Delete($this->aggregate($entity), $this->newQueryBuilder());

        $delete->execute();
    }
272220
protected function persist($entity)
    {
        $manager = $this->getDoctrine()->getManager();
        $manager->persist($entity);
        $manager->flush();
    }
1214999
public function remove(AbstractEntity $entity)
    {
        $this->getEntityManager()->remove($entity);
        $this->getEntityManager()->flush();
    }
998653
private function getEntityOnFlush($entity, $flushEntity)
    {
        if (ClassUtils::getClass($entity) == ClassUtils::getClass($flushEntity) && $entity->getId() === $flushEntity->getId()) {
            return $flushEntity;
        } else {
            return $entity;
        }
    }