@param PersistenceContext $context
@param Delete             $deleteQuery

@return void
768738
public function fireAfterDelete(PersistenceContext $context, Delete $deleteQuery)
    {
        $context->queue(new ResequenceOrderIndexColumn(
                $this->table,
                $this->orderColumn->getName(),
                $this->groupingColumn ? $this->groupingColumn->getName() : null
        ));
    }
77280
public function fireAfterPersist(PersistenceContext $context, array $objects, array $rows)
    {
        if ($this->orderPropertyName) {
            $orderColumn = $this->orderColumn->getName();

            foreach ($objects as $key => $object) {
                $object->hydrate([
                        $this->orderPropertyName => $rows[$key]->getColumn($orderColumn)
                ]);
            }
        }
    }
957651
void deleteReplica(Storable replica) throws PersistException {
        // Prevent trigger from being invoked by deleting replica.
        TriggerManager tm = mTriggerManager;
        tm.locallyDisableDelete();
        try {
            replica.delete();
        } finally {
            tm.locallyEnableDelete();
        }
    }
807063
private void performDeletion(final ClassDescriptor cld, final Object obj, final Identity oid, final boolean ignoreReferences) throws PersistenceBrokerException
    {
            // 1. delete dependend collections
            if (!ignoreReferences  && cld.getCollectionDescriptors().size() > 0)
            {
                deleteCollections(obj, cld.getCollectionDescriptors());
            }
            // 2. delete object from directly mapped table
            try
            {
                dbAccess.executeDelete(cld, obj); // use obj not oid to delete, BRJ
            }
            catch(OptimisticLockException e)
            {
                // ensure that the outdated object be removed from cache
                objectCache.remove(oid);
                throw e;
            }

            // 3. Add OID to the set of deleted objects
            deletedDuringTransaction.add(oid);

            // 4. delete dependend upon objects last to avoid FK violations
            if (cld.getObjectReferenceDescriptors().size() > 0)
            {
                deleteReferences(cld, obj, oid, ignoreReferences);
            }
            // remove obj from the object cache:
            objectCache.remove(oid);
    }
1278295
public static function delete_data_for_all_users_in_context(\context $context) {
        // Only delete data for a user context.
        if ($context->contextlevel == CONTEXT_USER) {
            static::delete_user_data($context->instanceid, $context);
        }
    }
1329168
public function flush(PersistableInterface $persistable, $forget = true)
    {
        if ($forget)
        {
            $this->forget();
        }

        $code = $this->check();

        $entityManager = $this->getEntityManager();
        $queryBuilder = $entityManager->createQueryBuilder();

        $queryBuilder
            ->delete($this->entityName(), 'p')
            ->where('p.user = :persistable')
            ->andWhere('p.code != :code');

        $queryBuilder->setParameters([
            'persistable' => $persistable,
            'code'        => $code
        ]);

        $queryBuilder->getQuery()->execute();
    }
273560
public function delete() {
        global $DB;

        if ($this->_contextlevel <= CONTEXT_SYSTEM) {
            throw new coding_exception('Cannot delete system context');
        }

        // double check the context still exists
        if (!$DB->record_exists('context', array('id'=>$this->_id))) {
            context::cache_remove($this);
            return;
        }

        $this->delete_content();
        $DB->delete_records('context', array('id'=>$this->_id));
        // purge static context cache if entry present
        context::cache_remove($this);
    }
219691
public function batchActionDelete(ProxyQueryInterface $query)
    {
        if (false === $this->admin->checkAccess('batchDelete')) {
            throw new AccessDeniedException();
        }

        try {
            $this->doBatchDelete($query);

            $this->addFlash('sonata_flash_success', 'flash_batch_delete_success');
        } catch (ModelManagerException $e) {
            $this->addFlash('sonata_flash_error', 'flash_batch_delete_error');
        }

        return new RedirectResponse($this->admin->generateUrl(
            'list',
            ['filter' => $this->admin->getFilterParameters()]
        ));
    }
338952
protected function _afterEntityDelete(AnCommandContext $context)
    {
        $this->ownable->getRepository()->getBehavior('sharable')->resetStats(array($this->ownable));
    }
519607
protected void deactivate(ComponentContext context) {
        destinationRef.deactivate(context);
        bootstrapContextRef.deactivate(context);
        rrsXAResFactorySvcRef.deactivate(context);
    }
858970
protected function _actionDelete(KDispatcherContextInterface $context)
    {
        $result     = false;
        $controller = $this->getController();

        if($controller instanceof KControllerModellable) {
            $result = $controller->execute('delete', $context);
        } else {
            throw new KDispatcherExceptionMethodNotAllowed('Method DELETE not allowed');
        }

        return $result;
    }
1168287
protected void deactivate(ComponentContext context) {
        final boolean trace = TraceComponent.isAnyTracingEnabled();

        // Block the progress of deactivate so that session manager is able to access the cache until it finishes stopping applications.
        // The approach of blocking is copied from DatabaseStoreService as a temporary workaround. It would be nice to have a better solution here.
        final long MAX_WAIT = TimeUnit.SECONDS.toNanos(10);
        for (long start = System.nanoTime(); !completedPassivation && System.nanoTime() - start < MAX_WAIT; )
            try {
                TimeUnit.MILLISECONDS.sleep(100); // sleep 1/10th of a second
            } catch (InterruptedException e) {
            }

        if (cachingProvider != null) {
            if (trace && tc.isDebugEnabled())
                CacheHashMap.tcInvoke(tcCachingProvider, "close");

            AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
                cachingProvider.close();
                return null;
            });

            if (trace && tc.isDebugEnabled())
                CacheHashMap.tcReturn(tcCachingProvider, "close");

            cachingProvider = null;
            cacheManager = null;
        }
    }
1095161
public function unscheduleCollectionDeletion(PersistentCollectionInterface $coll) : void
    {
        if ($coll->getOwner() === null) {
            return;
        }

        $oid = spl_object_hash($coll);
        if (! isset($this->collectionDeletions[$oid])) {
            return;
        }

        $topmostOwner = $this->getOwningDocument($coll->getOwner());
        unset($this->collectionDeletions[$oid]);
        unset($this->hasScheduledCollections[spl_object_hash($topmostOwner)][$oid]);
    }
974155
protected synchronized void deactivate(ComponentContext context) {
        cfwBundleRef.deactivate(context);
        scheduledExecSvcRef.deactivate(context);
        injectionServiceSRRef.deactivate(context);
        injectionService12SRRef.deactivate(context);
        executorServiceRef.deactivate(context);
        injectionEngineSRRef.deactivate(context);
    }
1196107
public static function delete_data_for_all_users_in_context(\context $context) {
        global $DB;

        // Sanity check that context is at the User context level.
        if ($context->contextlevel == CONTEXT_COURSE) {
            $sql = "SELECT ue.id
                      FROM {user_enrolments} ue
                      JOIN {enrol} e ON e.id = ue.enrolid
                     WHERE e.courseid = :courseid";
            $params = ['courseid' => $context->instanceid];
            $enrolsids = $DB->get_fieldset_sql($sql, $params);
            if (!empty($enrolsids)) {
                list($insql, $inparams) = $DB->get_in_or_equal($enrolsids, SQL_PARAMS_NAMED);
                static::delete_user_data($insql, $inparams);
            }
        }
    }
157978
public function persist(PersistenceContext $context, ParentChildMap $map)
    {
        /** @var Row[] $parentRows */
        $parentRows = [];
        /** @var object[] $children */
        $children = [];

        foreach ($map->getItems() as $key => $item) {
            $parentRow = $item->getParent();

            $hasChild = (bool)$item->getChild();
            if ($hasChild) {
                $parentRows[$key] = $parentRow;
                $children[$key]   = $item->getChild();
            }

            if ($this->objectIssetColumnName && !$this->isWithinValueObject) {
                $parentRow->setColumn($this->objectIssetColumnName, $hasChild);
            }
        }

        $this->disableLazyLoadingForRelations(function () use ($context, $children, $parentRows) {
            $this->mapper->persistAllToRows($context, $children, $parentRows);
        });
    }
1071232
public void executeDelete(Query query, ClassDescriptor cld) throws PersistenceBrokerException
    {
        if (logger.isDebugEnabled())
        {
            logger.debug("executeDelete (by Query): " + query);
        }
        final StatementManagerIF sm = broker.serviceStatementManager();
        PreparedStatement stmt = null;
        final String sql = this.broker.serviceSqlGenerator().getPreparedDeleteStatement(query, cld).getStatement();
        try
        {
            stmt = sm.getPreparedStatement(cld, sql,
                    false, StatementManagerIF.FETCH_SIZE_NOT_APPLICABLE, cld.getDeleteProcedure()!=null);

            sm.bindStatement(stmt, query, cld, 1);
            if (logger.isDebugEnabled())
                logger.debug("executeDelete (by Query): " + stmt);

            stmt.executeUpdate();
        }
        catch (SQLException e)
        {
            throw ExceptionHelper.generateException(e, sql, cld, null, logger);
        }
        finally
        {
            sm.closeResources(stmt, null);
        }
    }