src/ArchiveAdmin.php
public static function createArchiveGridField($title, $class)
    {
        $config = GridFieldConfig_Base::create();
        $config->removeComponentsByType(VersionedGridFieldState::class);
        $config->removeComponentsByType(GridFieldFilterHeader::class);
        $config->addComponent(new GridFieldDetailForm);
        $config->addComponent(new GridFieldViewButton);
        $config->addComponent(new GridFieldRestoreAction);
        $config->addComponent(new GridField_ActionMenu);

        $list = singleton($class)->get();
        $baseTable = singleton($list->dataClass())->baseTable();
        $liveTable = $baseTable . '_Live';

        $list = $list
            ->setDataQueryParam('Versioned.mode', 'latest_versions');
        // Join a temporary alias BaseTable_Draft, renaming this on execution to BaseTable
        // See Versioned::augmentSQL() For reference on this alias
        $draftTable = $baseTable . '_Draft';
        $list = $list
            ->leftJoin(
                $draftTable,
                "\"{$baseTable}\".\"ID\" = \"{$draftTable}\".\"ID\""
            );

        $list = $list->leftJoin(
            $liveTable,
            "\"{$baseTable}\".\"ID\" = \"{$liveTable}\".\"ID\""
        );

        $list = $list->where("\"{$draftTable}\".\"ID\" IS NULL");
        $list = $list->sort('LastEdited DESC');

        $field = GridField::create(
            $title,
            false,
            $list,
            $config
        );
        $field->setModelClass($class);

        return $field;
    }
public static function createArchiveGridField($title, $class)
    {
        $config = GridFieldConfig_Base::create();
        $config->removeComponentsByType(VersionedGridFieldState::class);
        $config->removeComponentsByType(GridFieldFilterHeader::class);
        $config->addComponent(new GridFieldDetailForm);
        $config->addComponent(new GridFieldViewButton);
        $config->addComponent(new GridFieldRestoreAction);
        $config->addComponent(new GridField_ActionMenu);

        $list = singleton($class)->get();
        $baseTable = singleton($list->dataClass())->baseTable();
        $liveTable = $baseTable . '_Live';

        $list = $list
            ->setDataQueryParam('Versioned.mode', 'latest_versions');
        // Join a temporary alias BaseTable_Draft, renaming this on execution to BaseTable
        // See Versioned::augmentSQL() For reference on this alias
        $draftTable = $baseTable . '_Draft';
        $list = $list
            ->leftJoin(
                $draftTable,
                "\"{$baseTable}\".\"ID\" = \"{$draftTable}\".\"ID\""
            );

        $list = $list->leftJoin(
            $liveTable,
            "\"{$baseTable}\".\"ID\" = \"{$liveTable}\".\"ID\""
        );

        $list = $list->where("\"{$draftTable}\".\"ID\" IS NULL");
        $list = $list->sort('LastEdited DESC');

        $field = GridField::create(
            $title,
            false,
            $list,
            $config
        );
        $field->setModelClass($class);

        return $field;
    }
public static function createArchiveGridField ( $ title , $ class ) { $ config = GridFieldConfig_Base :: create ( ) ; $ config -> removeComponentsByType ( VersionedGridFieldState :: class ) ; $ config -> removeComponentsByType ( GridFieldFilterHeader :: class ) ; $ config -> addComponent ( new GridFieldDetailForm ) ; $ config -> addComponent ( new GridFieldViewButton ) ; $ config -> addComponent ( new GridFieldRestoreAction ) ; $ config -> addComponent ( new GridField_ActionMenu ) ; $ list = singleton ( $ class ) -> get ( ) ; $ baseTable = singleton ( $ list -> dataClass ( ) ) -> baseTable ( ) ; $ liveTable = $ baseTable . '_Live' ; $ list = $ list -> setDataQueryParam ( 'Versioned.mode' , 'latest_versions' ) ; // Join a temporary alias BaseTable_Draft, renaming this on execution to BaseTable // See Versioned::augmentSQL() For reference on this alias $ draftTable = $ baseTable . '_Draft' ; $ list = $ list -> leftJoin ( $ draftTable , "\"{$baseTable}\".\"ID\" = \"{$draftTable}\".\"ID\"" ) ; $ list = $ list -> leftJoin ( $ liveTable , "\"{$baseTable}\".\"ID\" = \"{$liveTable}\".\"ID\"" ) ; $ list = $ list -> where ( "\"{$draftTable}\".\"ID\" IS NULL" ) ; $ list = $ list -> sort ( 'LastEdited DESC' ) ; $ field = GridField :: create ( $ title , false , $ list , $ config ) ; $ field -> setModelClass ( $ class ) ; return $ field ; }
Create a gridfield which displays archived objects

@param string $title
@param string $class
@return GridField
Create a gridfield which displays archived objects