/** * @return ArrayList */ private static function ExpiredDataObjects() { $data_objects = new ArrayList(); foreach (AutoArchivableExtension::getExtendedClasses() as $class_name) { $data_objects->merge(DataObject::get($class_name)->filter(array('AutoArchiveOn' => true, 'AutoArchiveDate:LessThanOrEqual' => date('Y-m-d')))); } return $data_objects; }
/** * Returns all pages that will be moved under this page when they will be archived in the future. Does not return * pages that are already located under this page. * * @param bool $include_disabled If true, also those pages will be returned that have AutoArchiveOn set to false. * @return ArrayList */ public function Archivables($include_disabled = false) { $result = new ArrayList(); $owner = $this->owner; foreach (AutoArchivableExtension::getExtendedClasses() as $class_name) { $archivables = SiteTree::get($class_name)->exclude('ParentID', $owner->ID); if (!$include_disabled) { $archivables = $archivables->exclude('AutoArchiveOn', false); } $result->merge($archivables->filterByCallback(function ($archivable) use($owner) { if ($archivable->getDestination()) { return $owner->ID == $archivable->getDestination()->ID; } else { return false; } })); } return $result; }