I'm creating a module for the cms which when installed needs to remove old pages (default installed pages) and create its own page.
In my requireDefaultRecords function I have this code which works to a certain extent.
$records = DataObject::get( "Page" );
foreach ( $records as $record )
It deletes the page and in the admin shows as deleted (strike through) However in the cms itself still shows up as a working page, my understanding at least should be because its been deleted shoudn't show in the CMS but only in the Admin marked as deleted. Although this is an issue its not the my main issue at hand. What I want to do is delete the page(s) from the sitetree completely that delete all history and everything associated with it. I thought getting all the versions of the record would work by but didn't have any affect.
/* in the loop */
$versions = $record->allVersions();
What is needed to happen to completely remove this pages.