Php 如何在Silverstripe 3.2中修改数据列表的阶段(阶段/活动)?

Php 如何在Silverstripe 3.2中修改数据列表的阶段(阶段/活动)?,php,web,silverstripe,Php,Web,Silverstripe,有人知道如何在Silverstripe 3.2中修改数据列表的阶段吗?我想修改网格字段组件中的数据列表,以便根据?\u GET['stage']参数进行更改。我解决了这个问题,如下所示 class GridFieldChangeStage implements GridField_DataManipulator { /* * Modifies the DataList stage accordingly */ public function getManipu

有人知道如何在Silverstripe 3.2中修改数据列表的阶段吗?我想修改网格字段组件中的数据列表,以便根据?\u GET['stage']参数进行更改。

我解决了这个问题,如下所示

class GridFieldChangeStage implements GridField_DataManipulator {
    /*
     * Modifies the DataList stage accordingly
     */
    public function getManipulatedData(GridField $gridField, SS_List $dataList)
    {
        $isShowingLiveData = (isset($_GET['stage']) && $_GET['stage'] == 'Live');
        if ($isShowingLiveData) {
            $dataList = $dataList->alterDataQuery(function($dataQuery) {
                $dataQuery->setQueryParam('Versioned.mode', 'stage');
                $dataQuery->setQueryParam('Versioned.stage', 'Live');
            });
        }
        return $dataList;
    }
}