Remove entities marked as deleted

@param PreFlushEventArgs $event
505578
public function preFlush(PreFlushEventArgs $event)
    {
        $entityManager = $event->getEntityManager();
        $uow = $entityManager->getUnitOfWork();

        foreach ($uow->getIdentityMap() as $class => $entities) {
            foreach ($entities as $entity) {
                if ($entity instanceof DeletableInterface) {
                    if ($entity->isDeleted()) {
                        $entityManager->remove($entity);
                    }
                }
            }
        }
    }
168315
public function onDelete(SubscriberEvent $event)
    {
        $this->listRepository->delete(
            $event->getListId(),
            $event->getSubscriber()
        );
    }
917320
public function forget(Event $event)
    {
        $this->cache->store($this->store)->forget($event->mutexName());
    }
338480
public function postFlush(PostFlushEventArgs $event)
    {
        $em = $event->getEntityManager();
        $valueCount = \count($this->valuesToPersist);
        foreach ($this->valuesToPersist as $value) {
            $em->persist($value);
        }
        $this->valuesToPersist = [];
        if ($valueCount > 0) {
            $em->flush();
        }
    }
244543
protected function detachPlugins($event)
    {
        if (\is_array($event->component->plugins_backend)) {
            foreach ($event->component->plugins_backend as $key_plugin => $value_plugin) {
                //Detach SEO plugin
                if ($key_plugin === 'seo' && $seo = LarrockAdminSeo::getModel()->whereSeoIdConnect($event->model->id)
                        ->whereSeoTypeConnect($event->component->name)->first()) {
                    $seo->delete();
                }
            }
        }
    }
813123
public static function onFlushPage(Event $event)
    {
        if (self::$onFlushPageAlreadyCalled) {
            return;
        }

        $page = $event->getTarget();
        if (!($page instanceof Page)) {
            return;
        }

        $application = $event->getApplication();
        $em = $application->getEntityManager();
        $uow = $em->getUnitOfWork();
        if ($uow->isScheduledForDelete($page)) {
            return;
        }

        $metadata = $application->getContainer()->get('nestednode.metadata.resolver')->resolve($page);
        $page->setMetaData($metadata);

        if ($uow->isScheduledForInsert($page) || $uow->isScheduledForUpdate($page)) {
            $uow->recomputeSingleEntityChangeSet($em->getClassMetadata('BackBee\NestedNode\Page'), $page);
        } elseif (!$uow->isScheduledForDelete($page)) {
            $uow->computeChangeSet($em->getClassMetadata('BackBee\NestedNode\Page'), $page);
        }

        self::$onFlushPageAlreadyCalled = true;
    }
772312
public function onDelete(GenericDataEvent $event)
    {
        /** @var UserEntity[] $users */
        $users = $event->getData();

        $ids = [];
        foreach ($users as $user) {
            $ids[] = $user->getId();
        }

        $this->manager->removeTaggedObjectsByClassAndIds(UserEntity::class, $ids);
    }
658025
public function onBeforeDeletePageCommit(BeforeDeletePageCommitEvent $event)
    {
        if ($event->isAborted()) {
            return;
        }

        $pageManager = $event->getContentManager();
        $pageRepository = $pageManager->getPageRepository();

        try {
            $languages = $this->languageRepository->activeLanguages();
            if (count($languages) > 0) {
                $result = null;
                $pageRepository->startTransaction();
                $idPage = $pageManager->get()->getId();
                foreach ($languages as $alLanguage) {
                    $result = $this->seoManager->deleteSeoAttributesFromLanguage($alLanguage->getId(), $idPage);
                    if (false === $result) break;
                }

                if (false !== $result) {
                    $pageRepository->commit();
                } else {
                    $pageRepository->rollBack();

                    $event->abort();
                }
            }
        } catch (\Exception $e) {
            $event->abort();
            if (isset($pageRepository) && $pageRepository !== null) {
                $pageRepository->rollBack();
            }

            throw $e;
        }
    }
603736
public function beforeDelete($event, $entity, $options)
    {
        $fields = $this->getFieldList();
        foreach ($fields as $field => $data) {
            $fieldConfig = $this->config($field);
            if ($fieldConfig['removeFileOnDelete']) {
                $this->_removeFile($entity->get($field));
            }
        }
    }
500692
public function preFlush(PreFlushEventArgs $eventArgs)
    {
        $entityManager = $eventArgs->getEntityManager();
        $unitOfWork = $entityManager->getUnitOfWork();

        foreach ($unitOfWork->getIdentityMap() as $entities) {
            foreach ($entities as $object) {
                $uploadableMeta = $this->getObjectExtendedMetadata($entityManager, $object);
                if (!$uploadableMeta->hasUploadableProperties()) {
                    continue;
                }
                $this->updateFiles($entityManager, $object, $uploadableMeta);
            }
        }
    }
225540
public function preDelete(DeleteEvent $event)
    {
        $aggregate = $event->getObject();

        foreach ($aggregate->getAnnouncements() as $announcement) {
            $this->crud->delete($announcement);
        }
    }
1364130
public function removeEvent($event) {
		$result = remove_entity_relationship($event->guid, self::EVENT_CALENDAR_RELATIONSHIP, $this->guid);

		if ($result) {
			// allow events to fire after confirmation that it has been added to the calendar
			elgg_trigger_event('events_api', 'remove_from_calendar', array('event' => $event, 'calendar' => $this));
		}

		return $result;
	}
878631
public function onRemove(LifecycleEventArgs $event)
    {
        $em = $event->getEntityManager();
        if (count($this->children)) {
            foreach ($this->children as $child) {
                $child->setParent(null);
                $em->persist($child);
            }
        }
        $this->enabled = false;
        $this->parent  = null;
        $this->name .= '-'.$this->getId().'-deleted';
        $this->slug .= '-'.$this->getId().'-deleted';
    }
275522
public function preRemove(Item $item, LifecycleEventArgs $event)
    {
        $interaction = $item->getInteraction();
        if (null !== $interaction) {
            $event->getEntityManager()->remove($interaction);
        }
    }
953490
public function preRemove(LifecycleEventArgs $args)
    {
        $entity = $args->getEntity();
        $this->translator->deleteTranslationData($entity);
    }
1299289
public static function remove(\core\event\base $event) {
        global $DB;

        $DB->delete_records(self::$table, array('cmid' => $event->contextinstanceid));
    }
705037
public function preRemove(LifecycleEventArgs $event)
    {
        $entity = $event->getEntity();

        if ($entity instanceOf ImageInterface) {
            $this->uploader->remove($entity);
        }
    }