Created
October 16, 2019 20:44
-
-
Save hissy/1f8aa186b5c0121e157528b3b8180e6b to your computer and use it in GitHub Desktop.
empty trash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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