code/CMSBatchAction.php
public function batchaction(SS_List $objs, $helperMethod, $successMessage, $arguments = array())
    {
        $status = array('modified' => array(), 'error' => array(), 'deleted' => array(), 'success' => array());

        foreach ($objs as $obj) {
            // Perform the action
            $id = $obj->ID;
            if (!call_user_func_array(array($obj, $helperMethod), $arguments)) {
                $status['error'][$id] = $id;
            } else {
                $status['success'][$id] = $id;
            }

            // Now make sure the tree title is appropriately updated
            $publishedRecord = DataObject::get_by_id($this->managedClass, $id);
            if ($publishedRecord) {
                $status['modified'][$id] = array(
                    'TreeTitle' => $publishedRecord->TreeTitle,
                );
            } else {
                $status['deleted'][$id] = $id;
            }
            $obj->destroy();
            unset($obj);
        }

        return $this->response($successMessage, $status);
    }
public function batchaction(SS_List $objs, $helperMethod, $successMessage, $arguments = array())
    {
        $status = array('modified' => array(), 'error' => array(), 'deleted' => array(), 'success' => array());

        foreach ($objs as $obj) {
            // Perform the action
            $id = $obj->ID;
            if (!call_user_func_array(array($obj, $helperMethod), $arguments)) {
                $status['error'][$id] = $id;
            } else {
                $status['success'][$id] = $id;
            }

            // Now make sure the tree title is appropriately updated
            $publishedRecord = DataObject::get_by_id($this->managedClass, $id);
            if ($publishedRecord) {
                $status['modified'][$id] = array(
                    'TreeTitle' => $publishedRecord->TreeTitle,
                );
            } else {
                $status['deleted'][$id] = $id;
            }
            $obj->destroy();
            unset($obj);
        }

        return $this->response($successMessage, $status);
    }
public function batchaction ( SS_List $ objs , $ helperMethod , $ successMessage , $ arguments = array ( ) ) { $ status = array ( 'modified' => array ( ) , 'error' => array ( ) , 'deleted' => array ( ) , 'success' => array ( ) ) ; foreach ( $ objs as $ obj ) { // Perform the action $ id = $ obj -> ID ; if ( ! call_user_func_array ( array ( $ obj , $ helperMethod ) , $ arguments ) ) { $ status [ 'error' ] [ $ id ] = $ id ; } else { $ status [ 'success' ] [ $ id ] = $ id ; } // Now make sure the tree title is appropriately updated $ publishedRecord = DataObject :: get_by_id ( $ this -> managedClass , $ id ) ; if ( $ publishedRecord ) { $ status [ 'modified' ] [ $ id ] = array ( 'TreeTitle' => $ publishedRecord -> TreeTitle , ) ; } else { $ status [ 'deleted' ] [ $ id ] = $ id ; } $ obj -> destroy ( ) ; unset ( $ obj ) ; } return $ this -> response ( $ successMessage , $ status ) ; }
Helper method for processing batch actions.
Returns a set of status-updating JavaScript to return to the CMS.

@param SS_List $objs The SS_List of objects to perform this batch action
on.
@param string $helperMethod The method to call on each of those objects.
@param string $successMessage
@param array $arguments
@return string JSON encoded map in the following format:
{
'modified': {
3: {'TreeTitle': 'Page3'},
5: {'TreeTitle': 'Page5'}
},
'deleted': {
// all deleted pages
}
}
Helper method for processing batch actions . Returns a set of status - updating JavaScript to return to the CMS .