Mark a entity as deleted
@return void
509077
public function markDeleted()
    {
        try {
            if( $repository = $this->r() ) {
                $repository->detach( $this );
            }
        } catch ( EntityMissingEntityManagerException $e ) {
        }
        $this->checksum = null;
        return $this;
    }
334669
public function deleteAction()
    {
        $record = (new \Cms\Orm\CmsCategoryTypeQuery)->findPk($this->id);
        if ($record && $record->delete()) {
            $this->getMessenger()->addMessage('messenger.categoryTypeAttribute.categoryType.deleted', true);
        }
        $this->getResponse()->redirect('cmsAdmin', 'categoryType');
    }
238203
public function clearAction()
    {
        /** @var Request $request */
        $request = $this->getRequest();
        $managerName = $request->getParam('objectManager', 'doctrine.entitymanager.orm_default');

        $entityMapCache = $this->getEntityMapCache();
        $result = "Entity map not found\n";
        if ($entityMapCache->hasEntityMap($managerName)) {
            $entityMapCache->deleteEntityMap($managerName);
            $result = "Entity map clear\n";
        }

        return [
            ConsoleModel::RESULT => $result
        ];
    }
811849
public function delete()
    {
        $this->brokenOnDelete = true;
        $this->onBeforeDelete();
        if ($this->brokenOnDelete) {
            user_error("$this->class has a broken onBeforeDelete() function."
            . " Make sure that you call parent::onBeforeDelete().", E_USER_ERROR);
        }

        $path = $this->getFullPath();
        if (file_exists($path)) {
            unlink($path);
        }
        if ($this->storeRecord) {
            $this->storeRecord->delete();
        }

        $this->flushCache();
        $this->onAfterDelete();
    }
791874
public function delete($entity)
    {
        $identifier   = $this->getIdentifier($entity);
        $affectedRows = $this->connection->delete($this->tableName, $identifier);

        if ($affectedRows == 0) {
            throw new OrmException("Entity not found.");
        }
    }
956077
protected function undelete()
    {
        if($this->saveButtonPushed())
        {
            $nodeRef = $this->buildCmsNodeRef();
            $node = $nodeRef->generateNode();
            $location = 'load';

            $this->Events->trigger('NodeCmsController.undelete'.'.'.$location,
                                    $this->errors, $this->templateVars, $node);

            foreach((array)$nodeRef->getElement()->getAspects() as $aspect)
                $this->Events->trigger('NodeCmsController.@'.$aspect->Slug.'.'.'undelete'.'.'.$location,
                                        $this->errors, $this->templateVars, $node);

            if (!$node->hasTitle())
                //get default form backing object
                $node = $this->RegulatedNodeService->getByNodeRef($node->getNodeRef());

            if (empty($node))
                throw new NotFoundException('Record not found for NodeRef: '.$nodeRef);

            // check permissions
            // $this->checkUndeletePermission($node);

            $location = 'pre';
            $this->Events->trigger('NodeCmsController.undelete'.'.'.$location,
                                            $this->errors, $this->templateVars, $node);

            foreach ((array)$nodeRef->getElement()->getAspects() as $aspect)
                $this->Events->trigger('NodeCmsController.@'.$aspect->Slug.'.'.'undelete'.'.'.$location,
                                            $this->errors, $this->templateVars, $node);

            $this->getErrors()->throwOnError();

            $this->RegulatedNodeService->undelete($nodeRef);

            $location = 'post';
            $this->Events->trigger('NodeCmsController.undelete'.'.'.$location, $this->errors, $this->templateVars, $node);
            foreach ((array)$nodeRef->getElement()->getAspects() as $aspect)
                $this->Events->trigger('NodeCmsController.@'.$aspect->Slug.'.'.'undelete'.'.'.$location, $this->errors, $this->templateVars, $node);


            //redirect to edit news (action_success_view)
            return new View($this->successView(), array('slug'=> $nodeRef->getSlug()));
        }
    }
664078
public function delete()
    {
        /*
         * TODO: https://github.com/sulu-io/sulu/pull/1171
         * This method needs to be refactored since in the first
         * iteration the logic was just moved from the Controller
         * to this class due to better reusability.
         */
        $delete = function($id) {
            /** @var Contact $contact */
            $contact = $this->contactRepository->findByIdAndDelete($id);

            if (!$contact) {
                throw new EntityNotFoundException($this->contactRepository->getClassName(), $id);
            }

            $addresses = $contact->getAddresses();
            /** @var Address $address */
            foreach ($addresses as $address) {
                if (!$address->hasRelations()) {
                    $this->em->remove($address);
                }
            }

            $phones = $contact->getPhones()->toArray();
            /** @var Phone $phone */
            foreach ($phones as $phone) {
                if (0 == $phone->getAccounts()->count() && 1 == $phone->getContacts()->count()) {
                    $this->em->remove($phone);
                }
            }
            $emails = $contact->getEmails()->toArray();
            /** @var Email $email */
            foreach ($emails as $email) {
                if (0 == $email->getAccounts()->count() && 1 == $email->getContacts()->count()) {
                    $this->em->remove($email);
                }
            }

            $urls = $contact->getUrls()->toArray();
            /** @var Url $url */
            foreach ($urls as $url) {
                if (0 == $url->getAccounts()->count() && 1 == $url->getContacts()->count()) {
                    $this->em->remove($url);
                }
            }

            $faxes = $contact->getFaxes()->toArray();
            /** @var Fax $fax */
            foreach ($faxes as $fax) {
                if (0 == $fax->getAccounts()->count() && 1 == $fax->getContacts()->count()) {
                    $this->em->remove($fax);
                }
            }

            $socialMediaProfiles = $contact->getSocialMediaProfiles()->toArray();
            /** @var SocialMediaProfile $socialMediaProfile */
            foreach ($socialMediaProfiles as $socialMediaProfile) {
                if (0 == $socialMediaProfile->getAccounts()->count()
                    && 1 == $socialMediaProfile->getContacts()->count()
                ) {
                    $this->em->remove($socialMediaProfile);
                }
            }

            $notes = $contact->getNotes()->toArray();
            /** @var Note $note */
            foreach ($notes as $note) {
                if (0 == $note->getAccounts()->count() && 1 == $note->getContacts()->count()) {
                    $this->em->remove($note);
                }
            }

            $this->em->remove($contact);
            $this->em->flush();
        };

        return $delete;
    }
1208559
public function afterDelete()
    {
        $owner = $this->owner;
        $condition = $this->getCondition();
        $condition[] = ['>', $this->sortAttribute, $owner->{$this->sortAttribute}];
        $owner->updateAllCounters([$this->sortAttribute => -1], $condition);
    }
387315
def mark_clean(self, entity):
        
        state = EntityState.get_state(entity)
        state.status = ENTITY_STATUS.CLEAN
        state.is_persisted = True
791943
private function commitRemoved()
    {
        $documents = $this->sortObjects($this->scheduledForDelete, false);
        $client = $this->sm->getClient();

        foreach ($documents as $entityName => $documents) {
            $classMetadata = $this->sm->getClassMetadata($entityName);
            $this->updatedIndexes[] = $classMetadata->index;
            $client->removeDocuments($classMetadata, $documents);
        }
    }
866842
protected function delete()
    {
        if ($this->executed) {
            return;
        }

        $request = new Request(Request::DELETE);
        $request->setHost($this->app->getHost())
            ->setEndpoint(self::ENDPOINT)
            ->setCredentials($this->app->getAppId(), $this->app->getSecretKey());

        $result = $request->send(
            [
                "reference_id" => $this->referenceId
            ]
        );

        $result->getData();
        $this->executed = true;
    }
872342
public function delete($entity)
    {
        $this->_em->remove($entity);
        $this->_em->flush($entity);
    }
475032
public function deleteAction()
    {
        $label = (new \Cms\Orm\CmsStatLabelQuery)->findPk($this->id);
        if ($label && $label->delete()) {
            $this->getMessenger()->addMessage('messenger.stat.deleted', true);
        }
        $this->getResponse()->redirect('cmsAdmin', 'stat', 'label');
    }
209178
public function afterDelete()
	{
		if (parent::beforeDelete()) {
			Comment::deleteAll('comment_id='.$this->id.' AND comment_table="'.self::MODULE_BLOG.'"');
			Tag::updateFrequency($this->tags, '');
		} else {
			return false;
		}
	}
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;
    }
131244
protected function doDelete($entityId)
    {
        $entity = $this->find($entityId);

        if (method_exists($entity, 'setDeleted')) {
            $entity->setDeleted(true);
            $this->save($entity);

            return true;
        }

        $this->getEntityManager()->remove($entity);
        $this->getEntityManager()->flush($entity);

        return true;
    }
1214032
public function postDelete()
    {
        RevisionRepository::create([
            'revisionable_type' => get_class($this),
            'revisionable_id'   => $this->getKey(),
            'key'               => 'deleted_at',
            'old_value'         => null,
            'new_value'         => new DateTime(),
            'user_id'           => $this->getUserId(),
        ]);
    }