Skip to content

Instantly share code, notes, and snippets.

@hissy
Created October 16, 2019 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hissy/1f8aa186b5c0121e157528b3b8180e6b to your computer and use it in GitHub Desktop.
Save hissy/1f8aa186b5c0121e157528b3b8180e6b to your computer and use it in GitHub Desktop.
empty trash
<?php
use Concrete\Core\Page\Page;
use Concrete\Core\Page\PageList;
use Concrete\Core\Support\Facade\Facade;
$app = Facade::getFacadeApplication();
$app->make('cache/request')->disable();
$app->make('cache/expensive')->disable();
$app->make('cache')->disable();
/** @var \Concrete\Core\Config\Repository\Liaison $config */
$config = $app->make('config');
$trash = Page::getByPath($config->get('concrete.paths.trash'));
$i = 0;
if (is_object($trash) && !$trash->isError()) {
$pl = new PageList();
$pl->ignorePermissions();
$pl->filterByParentID($trash->getCollectionID());
$pl->includeInactivePages();
$pl->includeSystemPages();
$pl->sortByCollectionIDAscending();
$pages = $pl->getResults();
foreach ($pages as $pc) {
$pc->delete();
++$i;
}
} else {
echo t('Trash not found.');
}
echo t2('%d page deleted.', '%d pages deleted.', $i);
echo PHP_EOL;
die();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment