Delete page collecton.

@return \Symfony\Component\HttpFoundation\JsonResponse

@Rest\Security("is_fully_authenticated() & has_role('ROLE_API_USER')")
186491
public function deleteCollectionAction(Request $request)
    {
        if (null === $uids = $request->get('uids', null)) {
            throw new BadRequestHttpException('uid is missing.');
        }

        $result = [];
        $statusCode = 204;
        $pages = $this->getPageRepository()->findBy(['_uid' => $uids]);
        foreach ($pages as $page) {
            try {
                if ($page->isDeleted()) {
                    $this->hardDelete($page);
                } else {
                    $this->softDelete($page);
                }

                $result[] = [
                    'uid'        => $page->getUid(),
                    'statusCode' => 204,
                    'message'    => 'OK',
                ];
            } catch (AccessDeniedException $e) {
                $result[] = [
                    'uid'        => $page->getUid(),
                    'statusCode' => 401,
                    'message'    => $e->getMessage(),
                ];
                $statusCode = ($statusCode < 401) ? 401 : $statusCode;
            } catch (\Exception $e) {
                if ($e instanceof BadRequestHttpException || $e instanceof InsufficientAuthenticationException) {
                    $result[] = [
                        'uid'        => $page->getUid(),
                        'statusCode' => 403,
                        'message'    => $e->getMessage(),
                    ];
                    $statusCode = ($statusCode < 403) ? 403 : $statusCode;
                } else {
                    $result[] = [
                        'uid'        => $page->getUid(),
                        'statusCode' => 500,
                        'message'    => $e->getMessage(),
                    ];
                    $statusCode = ($statusCode < 500) ? 500 : $statusCode;
                }
            }
        }

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

        return $this->createJsonResponse($result, $statusCode);
    }
414463
public function delete()
    {
        $app = Facade::getFacadeApplication();
        $db = $app->make('database')->connection();

        $cvID = $this->cvID;
        $c = Page::getByID($this->cID, $cvID);
        $cID = $c->getCollectionID();

        $q = "select bID, arHandle from CollectionVersionBlocks where cID = ? and cvID = ?";
        $r = $db->executeQuery($q, array(
            $cID,
            $cvID,
        ));
        while ($row = $r->fetch()) {
            if ($row['bID']) {
                $b = Block::getByID($row['bID'], $c, $row['arHandle']);
                if (is_object($b)) {
                    $b->deleteBlock();
                }
                unset($b);
            }
        }

        $features = CollectionVersionFeatureAssignment::getList($this);
        foreach ($features as $fa) {
            $fa->delete();
        }

        $category = $app->make('Concrete\Core\Attribute\Category\PageCategory');
        $attributes = $category->getAttributeValues($this);
        foreach ($attributes as $attribute) {
            $category->deleteValue($attribute);
        }

        $db->executeQuery('delete from CollectionVersionBlockStyles where cID = ? and cvID = ?', array(
            $cID,
            $cvID,
        ));
        $db->executeQuery('delete from CollectionVersionThemeCustomStyles where cID = ? and cvID = ?', array(
            $cID,
            $cvID,
        ));
        $db->executeQuery('delete from CollectionVersionRelatedEdits where cID = ? and cvID = ?', array(
            $cID,
            $cvID,
        ));
        $db->executeQuery('delete from CollectionVersionAreaStyles where cID = ? and cvID = ?', array(
            $cID,
            $cvID,
        ));

        $db->executeQuery('delete from PageTypeComposerOutputBlocks where cID = ? and cvID = ?', array(
            $cID,
            $cvID,
        ));

        $q = "delete from CollectionVersions where cID = '{$cID}' and cvID='{$cvID}'";
        $db->executeQuery($q);
        $this->refreshCache();
    }
309098
function delete ()
    {
        global $config;
        $query = sprintf(
            file_get_contents("sql/deletePage.sql"),
            mysql_real_escape_string($this->id)
        );
        $config->connexionBdd->requete($query);
    }
1074264
public function delete()
    {
        return $this->forge->deleteCertificate($this->serverId, $this->siteId, $this->id);
    }
68091
public function delete()
    {
        $cID = $this->getCollectionID();

        if ($this->isAliasPage()) {
            $this->removeThisAlias();

            return;
        }

        if ($cID < 1 || $cID == static::getHomePageID()) {
            return false;
        }

        $db = Database::connection();

        // run any internal event we have for page deletion
        $pe = new DeletePageEvent($this);
        Events::dispatch('on_page_delete', $pe);

        if (!$pe->proceed()) {
            return false;
        }

        $app = Facade::getFacadeApplication();
        $logger = $app->make('log/factory')->createLogger(Channels::CHANNEL_SITE_ORGANIZATION);
        $logger->notice(t('Page "%s" at path "%s" deleted',
            $this->getCollectionName(),
            $this->getCollectionPath()
        ));

        parent::delete();

        $cID = $this->getCollectionID();

        // Now that all versions are gone, we can delete the collection information
        $q = "delete from PagePaths where cID = '{$cID}'";
        $r = $db->query($q);

        // remove all pages where the pointer is this cID
        $r = $db->executeQuery('select cID from Pages where cPointerID = ?', [$cID]);
        while ($row = $r->fetchRow()) {
            PageStatistics::decrementParents($row['cID']);
            $db->executeQuery('DELETE FROM PagePaths WHERE cID=?', [$row['cID']]);
        }

        // Update cChildren for cParentID
        PageStatistics::decrementParents($cID);

        $db->executeQuery('delete from PagePermissionAssignments where cID = ?', [$cID]);

        $db->executeQuery('delete from Pages where cID = ?', [$cID]);

        $db->executeQuery('delete from MultilingualPageRelations where cID = ?', [$cID]);

        $db->executeQuery('delete from SiblingPageRelations where cID = ?', [$cID]);

        $db->executeQuery('delete from Pages where cPointerID = ?', [$cID]);

        $db->executeQuery('delete from Areas WHERE cID = ?', [$cID]);

        $db->executeQuery('delete from PageSearchIndex where cID = ?', [$cID]);

        $r = $db->executeQuery('select cID from Pages where cParentID = ?', [$cID]);
        if ($r) {
            while ($row = $r->fetchRow()) {
                if ($row['cID'] > 0) {
                    $nc = self::getByID($row['cID']);
                    $nc->delete();
                }
            }
        }

        if (\Core::make('multilingual/detector')->isEnabled()) {
            Section::unregisterPage($this);
        }

        $cache = PageCache::getLibrary();
        $cache->purge($this);
    }
204605
public function destroy(Request $request, Role $role)
    {
        $this->authorize('delete', Role::class);
        $role->deletePermissions($role->permissions);
        $role->deleteUsers($role->users);

        $role->delete();

        return redirect()->route('laralum::roles.index')->with('success', __('laralum_roles::general.role_deleted', ['id' => $role->id]));
    }
1058787
public function removeAction(Request $request): Response
    {
        $form = $this->formFactory->removeBookmark(
            new BookmarkRemoveData()
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (BookmarkRemoveData $data) {
                foreach ($data->getBookmarks() as $locationId => $selected) {
                    $this->bookmarkService->deleteBookmark(
                        $this->locationService->loadLocation($locationId)
                    );
                }

                return $this->redirectToRoute('ezplatform.bookmark.list');
            });

            if ($result instanceof Response) {
                return $result;
            }
        }

        return $this->redirectToRoute('ezplatform.bookmark.list');
    }
230609
public function trashAction()
    {
        /** @var AbstractAdmin $admin */
        $admin = $this->getAdmin();

        $admin->checkAccess('undelete');

        /** @var EntityManager $em */
        $em = $this->get('doctrine')->getManager();

        $filters = $em->getFilters();

        if ($filters->isEnabled('softdeleteable')) {
            $filters->disable('softdeleteable');
        }

        if (!$filters->isEnabled('softdeleteabletrash')) {
            $filters->enable('softdeleteabletrash');
        }

        /** @var SoftDeleteableTrashFilter $softdeleteabletrash */
        $softdeleteabletrash = $filters->getFilter('softdeleteabletrash');

        $softdeleteabletrash->enableForEntity($admin->getClass());

        $datagrid = $admin->getDatagrid();
        $formView = $datagrid->getForm()->createView();

        // set the theme for the current Admin Form
        $this->get('twig')->getExtension(FormExtension::class)->renderer->setTheme($formView, $admin->getFilterTheme());

        return $this->renderWithExtraParams('@CompoSonataAdmin/CRUD/trash.html.twig', [
            'action' => 'trash',
            'form' => $formView,
            'datagrid' => $datagrid,
            'csrf_token' => $this->getCsrfToken('sonata.batch'),
        ]);
    }
174121
public function deleteAction()
    {
        $entity = $this->loadEntity();
        //TODO: change method to post maybe
        $objectManager = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');
        $objectManager->remove($entity);
        $objectManager->flush();

        $controller = explode('/', $this->getRequest()->getUri()->getPath())[2];

        if (!$this->getRequest()->isXmlHttpRequest()) {
            return $this->redirect()->toRoute(null, ['controller' => $controller]);
        }
        return;
    }
442552
public function deleteAction(Request $request)
    {
        try {
            $manager = $this->get('ongr_settings.settings_manager');
            $manager->delete($request->get('name'));

            return new JsonResponse(['error' => false]);
        } catch (\Exception $e) {
            return new JsonResponse(
                [
                    'error' => true,
                    'message' => 'Error occurred please try to delete setting again.'
                ]
            );
        }
    }
301
public function collectAction()
    {
        // @todo json
        $service = $this->getGarbageCollector();
        if ($service->collect()) {
            return $this->redirect()->toRoute('sc-admin/content-manager');
        }
        return $this->redirect()
            ->toRoute(
                'sc-admin/file/delete',
                ['random' => Stdlib::randomKey(6)]
            )
            ->setStatusCode(303);
    }
917139
public function delete($id)
    {
        $id = (int)$id;
        $siteId = $this->getRequestSiteId();

        //ACCESS CHECK
        $sitePagesResource = $this->getSitePagesResourceId($siteId);
        if (!$this->isAllowed('pages', 'delete')
            && !$this->isAllowed(
                $sitePagesResource,
                'delete'
            )
        ) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);

            return new ApiJsonModel(
                null,
                1,
                "Access denied"
            );
        }

        $site = $this->getSite($siteId);

        if (empty($site)) {
            return new ApiJsonModel(
                null,
                1,
                "Site was not found with id {$siteId}."
            );
        }

        $page = $this->getPage($site, $id);

        if (empty($page)) {
            return new ApiJsonModel(
                null,
                404,
                "Page was not found with id {$id}."
            );
        }

        $this->pageMutationService->depublishPage($this->getCurrentUser(), $page);

        return new ApiJsonModel([true], 0, 'Page deleted');
    }
78084
public function deleteAction()
    {
        // Check current user authorization
        if (null !== $response = $this->checkAuth($this->resourceCode, $this->getModuleCode(), AccessManager::DELETE)) {
            return $response;
        }

        try {
            // Check token
            $this->getTokenProvider()->checkToken(
                $this->getRequest()->query->get("_token")
            );

            // Get the currency id, and dispatch the delete request
            $deleteEvent = $this->getDeleteEvent();

            $this->dispatch($this->deleteEventIdentifier, $deleteEvent);

            if (null !== $deletedObject = $this->getObjectFromEvent($deleteEvent)) {
                $this->adminLogAppend(
                    $this->resourceCode,
                    AccessManager::DELETE,
                    sprintf(
                        "%s %s (ID %s) deleted",
                        ucfirst($this->objectName),
                        $this->getObjectLabel($deletedObject),
                        $this->getObjectId($deletedObject)
                    ),
                    $this->getObjectId($deletedObject)
                );
            }

            $response = $this->performAdditionalDeleteAction($deleteEvent);

            if ($response == null) {
                return $this->redirectToListTemplate();
            } else {
                return $response;
            }
        } catch (\Exception $e) {
            return $this->renderAfterDeleteError($e);
        }
    }
1187501
public function clearAction()
    {
        if (!$this->checkLivePermissionForAllWebspaces()) {
            return new JsonResponse(null, 403);
        }

        $this->get('sulu_website.http_cache.clearer')->clear();

        return new JsonResponse(null, 204);
    }
1297880
public function delete()
    {
        $recordFinder = GeneralUtility::makeInstance(RecordFinder::class);

        $commands = [];

        // Delete page tree and all their records on this tree
        $topUids = $recordFinder->findUidsOfStyleguideEntryPages();
        if (!empty($topUids)) {
            foreach ($topUids as $topUid) {
                $commands['pages'][(int)$topUid]['delete'] = 1;
            }
        }

        // Delete all the sys_language demo records
        $languageUids = $recordFinder->findUidsOfDemoLanguages();
        if (!empty($languageUids)) {
            foreach ($languageUids as $languageUid) {
                $commands['sys_language'][(int)$languageUid]['delete'] = 1;
            }
        }

        // Delete demo users
        $demoUserUids = $recordFinder->findUidsOfDemoBeUsers();
        if (!empty($demoUserUids)) {
            foreach ($demoUserUids as $demoUserUid) {
                $commands['be_users'][(int)$demoUserUid]['delete'] = 1;
            }
        }

        // Delete demo groups
        $demoGroupUids = $recordFinder->findUidsOfDemoBeGroups();
        if (!empty($demoGroupUids)) {
            foreach ($demoGroupUids as $demoUserGroup) {
                $commands['be_groups'][(int)$demoUserGroup]['delete'] = 1;
            }
        }

        // Do the thing
        if (!empty($commands)) {
            $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
            $dataHandler->deleteTree = true;
            $dataHandler->start([], $commands);
            $dataHandler->process_cmdmap();
            BackendUtility::setUpdateSignal('updatePageTree');
        }

        // Delete demo images in fileadmin again
        $storageRepository = GeneralUtility::makeInstance(StorageRepository::class);
        $storage = $storageRepository->findByUid(1);
        $folder = $storage->getRootLevelFolder();
        try {
            $folder = $folder->getSubfolder('styleguide');
            $folder->delete(true);
        } catch (\InvalidArgumentException $e) {
            // No op if folder does not exist
        }
    }
1282425
public function removeThisAlias()
    {
        if ($this->isExternalLink()) {
            $this->delete();
        } elseif ($this->isAliasPage()) {
            $cIDRedir = $this->getCollectionPointerID();
            $db = Database::connection();

            PageStatistics::decrementParents($this->getCollectionPointerOriginalID());

            $args = [$this->getCollectionPointerOriginalID()];
            $q = 'delete from Pages where cID = ?';
            $db->executeQuery($q, $args);

            $q = 'delete from Collections where cID = ?';
            $db->executeQuery($q, $args);

            $q = 'delete from CollectionVersions where cID = ?';
            $db->executeQuery($q, $args);

            $q = 'delete from PagePaths where cID = ?';
            $db->executeQuery($q, $args);

            return $cIDRedir;
        }
    }
915762
public function delete(Page $page)
    {
        $endpoint = '/admin/pages/'.$page->id.'.json';
        $response = $this->request($endpoint, 'DELETE');
        return;
    }