src/Reports/PagesDueForReviewReport.php
public function sourceRecords($params = [])
    {
        Versioned::set_stage(Versioned::DRAFT);

        $records = SiteTree::get();
        $compatibility = ContentReviewCompatability::start();

        if (empty($params['ReviewDateBefore']) && empty($params['ReviewDateAfter'])) {
            // If there's no review dates set, default to all pages due for review now
            $records = $records->where(
                sprintf(
                    '"NextReviewDate" < \'%s\'',
                    DBDatetime::now()->Format('y-MM-dd')
                )
            );
        } else {
            // Review date before
            if (!empty($params['ReviewDateBefore'])) {
                // TODO Get value from DateField->dataValue() once we have access to form elements here
                $nextReviewUnixSec = strtotime(
                    ' + 1 day',
                    strtotime($params['ReviewDateBefore'])
                );
                $records = $records->where(
                    sprintf(
                        "\"NextReviewDate\" < '%s'",
                        DBDatetime::create()->setValue($nextReviewUnixSec)->Format('y-MM-dd')
                    )
                );
            }

            // Review date after
            if (!empty($params['ReviewDateAfter'])) {
                // TODO Get value from DateField->dataValue() once we have access to form elements here
                $records = $records->where(
                    sprintf(
                        "\"NextReviewDate\" >= '%s'",
                        DBDatetime::create()->setValue(strtotime($params['ReviewDateAfter']))->Format('y-MM-dd')
                    )
                );
            }
        }

        // Show virtual pages?
        if (empty($params["ShowVirtualPages"])) {
            $virtualPageClasses = ClassInfo::subclassesFor(VirtualPage::class);
            $records = $records->where(sprintf(
                "\"SiteTree\".\"ClassName\" NOT IN ('%s')",
                implode("','", array_values($virtualPageClasses))
            ));
        }

        // Owner dropdown
        if (!empty($params[ContentReviewOwner::class])) {
            $ownerNames = Convert::raw2sql($params[ContentReviewOwner::class]);
            $records = $records->filter("OwnerNames:PartialMatch", $ownerNames);
        }

        // Only show pages assigned to the current user?
        // This come last because it transforms $records to an ArrayList.
        if (!empty($params["OnlyMyPages"])) {
            $currentUser = Security::getCurrentUser();

            $records = $records->filterByCallback(function ($page) use ($currentUser) {
                $options = $page->getOptions();

                if ($options) {
                    foreach ($options->ContentReviewOwners() as $owner) {
                        if ($currentUser->ID == $owner->ID) {
                            return true;
                        }
                    }
                }

                return false;
            });
        }

        ContentReviewCompatability::done($compatibility);

        return $records;
    }
public function sourceRecords($params = [])
    {
        Versioned::set_stage(Versioned::DRAFT);

        $records = SiteTree::get();
        $compatibility = ContentReviewCompatability::start();

        if (empty($params['ReviewDateBefore']) && empty($params['ReviewDateAfter'])) {
            // If there's no review dates set, default to all pages due for review now
            $records = $records->where(
                sprintf(
                    '"NextReviewDate" < \'%s\'',
                    DBDatetime::now()->Format('y-MM-dd')
                )
            );
        } else {
            // Review date before
            if (!empty($params['ReviewDateBefore'])) {
                // TODO Get value from DateField->dataValue() once we have access to form elements here
                $nextReviewUnixSec = strtotime(
                    ' + 1 day',
                    strtotime($params['ReviewDateBefore'])
                );
                $records = $records->where(
                    sprintf(
                        "\"NextReviewDate\" < '%s'",
                        DBDatetime::create()->setValue($nextReviewUnixSec)->Format('y-MM-dd')
                    )
                );
            }

            // Review date after
            if (!empty($params['ReviewDateAfter'])) {
                // TODO Get value from DateField->dataValue() once we have access to form elements here
                $records = $records->where(
                    sprintf(
                        "\"NextReviewDate\" >= '%s'",
                        DBDatetime::create()->setValue(strtotime($params['ReviewDateAfter']))->Format('y-MM-dd')
                    )
                );
            }
        }

        // Show virtual pages?
        if (empty($params["ShowVirtualPages"])) {
            $virtualPageClasses = ClassInfo::subclassesFor(VirtualPage::class);
            $records = $records->where(sprintf(
                "\"SiteTree\".\"ClassName\" NOT IN ('%s')",
                implode("','", array_values($virtualPageClasses))
            ));
        }

        // Owner dropdown
        if (!empty($params[ContentReviewOwner::class])) {
            $ownerNames = Convert::raw2sql($params[ContentReviewOwner::class]);
            $records = $records->filter("OwnerNames:PartialMatch", $ownerNames);
        }

        // Only show pages assigned to the current user?
        // This come last because it transforms $records to an ArrayList.
        if (!empty($params["OnlyMyPages"])) {
            $currentUser = Security::getCurrentUser();

            $records = $records->filterByCallback(function ($page) use ($currentUser) {
                $options = $page->getOptions();

                if ($options) {
                    foreach ($options->ContentReviewOwners() as $owner) {
                        if ($currentUser->ID == $owner->ID) {
                            return true;
                        }
                    }
                }

                return false;
            });
        }

        ContentReviewCompatability::done($compatibility);

        return $records;
    }
@param array $params

@return SS_List