src/VersionedGridFieldItemRequest.php
public function doArchive($data, $form)
    {
        /** @var Versioned|DataObject $record */
        $record = $this->getRecord();
        if (!$record->canArchive()) {
            return $this->httpError(403);
        }

        // Record name before it's deleted
        $title = $record->Title;
        $record->doArchive();

        $message = _t(
            __CLASS__ . '.Archived',
            'Archived {name} {title}',
            [
                'name' => $record->i18n_singular_name(),
                'title' => Convert::raw2xml($title)
            ]
        );
        $this->setFormMessage($form, $message);

        //when an item is deleted, redirect to the parent controller
        $controller = $this->getToplevelController();
        $controller->getRequest()->addHeader('X-Pjax', 'Content'); // Force a content refresh

        return $controller->redirect($this->getBackLink(), 302); //redirect back to admin section
    }
public function doArchive($data, $form)
    {
        /** @var Versioned|DataObject $record */
        $record = $this->getRecord();
        if (!$record->canArchive()) {
            return $this->httpError(403);
        }

        // Record name before it's deleted
        $title = $record->Title;
        $record->doArchive();

        $message = _t(
            __CLASS__ . '.Archived',
            'Archived {name} {title}',
            [
                'name' => $record->i18n_singular_name(),
                'title' => Convert::raw2xml($title)
            ]
        );
        $this->setFormMessage($form, $message);

        //when an item is deleted, redirect to the parent controller
        $controller = $this->getToplevelController();
        $controller->getRequest()->addHeader('X-Pjax', 'Content'); // Force a content refresh

        return $controller->redirect($this->getBackLink(), 302); //redirect back to admin section
    }
public function doArchive ( $ data , $ form ) { /** @var Versioned|DataObject $record */ $ record = $ this -> getRecord ( ) ; if ( ! $ record -> canArchive ( ) ) { return $ this -> httpError ( 403 ) ; } // Record name before it's deleted $ title = $ record -> Title ; $ record -> doArchive ( ) ; $ message = _t ( __CLASS__ . '.Archived' , 'Archived {name} {title}' , [ 'name' => $ record -> i18n_singular_name ( ) , 'title' => Convert :: raw2xml ( $ title ) ] ) ; $ this -> setFormMessage ( $ form , $ message ) ; //when an item is deleted, redirect to the parent controller $ controller = $ this -> getToplevelController ( ) ; $ controller -> getRequest ( ) -> addHeader ( 'X-Pjax' , 'Content' ) ; // Force a content refresh return $ controller -> redirect ( $ this -> getBackLink ( ) , 302 ) ; //redirect back to admin section }
Archive this versioned record

@param array $data
@param Form $form
@return HTTPResponse
Archive this versioned record