protected function saveAllRecords(\GridField $grid, $arguments, $data) { if (isset($data[$grid->Name])) { $currValue = $grid->Value(); $grid->setValue($data[$grid->Name]); $model = singleton($grid->List->dataClass()); foreach ($grid->getConfig()->getComponents() as $component) { if ($component instanceof \GridField_SaveHandler) { $component->handleSave($grid, $model); } } if ($this->publish) { // Only use the viewable list items, since bulk publishing can take a toll on the system $list = ($paginator = $grid->getConfig()->getComponentByType('GridFieldPaginator')) ? $paginator->getManipulatedData($grid, $grid->List) : $grid->List; $list->each(function ($item) { if ($item->hasExtension('Versioned')) { $item->writeToStage('Stage'); $item->publish('Stage', 'Live'); } }); } if ($model->exists()) { $model->delete(); $model->destroy(); } $grid->setValue($currValue); if (\Controller::curr() && ($response = \Controller::curr()->Response)) { if (!$this->completeMessage) { $this->completeMessage = _t('GridField.DONE', 'Done.'); } $response->addHeader('X-Status', rawurlencode($this->completeMessage)); } } }