src/VersionedGridFieldItemRequest.php
public function doPublish($data, $form)
    {
        /** @var Versioned|RecursivePublishable|DataObject $record */
        $record = $this->getRecord();
        $isNewRecord = $record->ID == 0;

        // Check permission
        if (!$record->canPublish()) {
            return $this->httpError(403);
        }

        // Initial save and reload
        $record = $this->saveFormIntoRecord($data, $form);
        $record->publishRecursive();

        $editURL = $this->Link('edit');
        $xmlTitle = Convert::raw2xml($record->Title);
        $link = "<a href=\"{$editURL}\">{$xmlTitle}</a>";
        $message = _t(
            __CLASS__ . '.Published',
            'Published {name} {link}',
            [
                'name' => $record->i18n_singular_name(),
                'link' => $link
            ]
        );
        $this->setFormMessage($form, $message);

        return $this->redirectAfterSave($isNewRecord);
    }
public function doPublish($data, $form)
    {
        /** @var Versioned|RecursivePublishable|DataObject $record */
        $record = $this->getRecord();
        $isNewRecord = $record->ID == 0;

        // Check permission
        if (!$record->canPublish()) {
            return $this->httpError(403);
        }

        // Initial save and reload
        $record = $this->saveFormIntoRecord($data, $form);
        $record->publishRecursive();

        $editURL = $this->Link('edit');
        $xmlTitle = Convert::raw2xml($record->Title);
        $link = "<a href=\"{$editURL}\">{$xmlTitle}</a>";
        $message = _t(
            __CLASS__ . '.Published',
            'Published {name} {link}',
            [
                'name' => $record->i18n_singular_name(),
                'link' => $link
            ]
        );
        $this->setFormMessage($form, $message);

        return $this->redirectAfterSave($isNewRecord);
    }
public function doPublish ( $ data , $ form ) { /** @var Versioned|RecursivePublishable|DataObject $record */ $ record = $ this -> getRecord ( ) ; $ isNewRecord = $ record -> ID == 0 ; // Check permission if ( ! $ record -> canPublish ( ) ) { return $ this -> httpError ( 403 ) ; } // Initial save and reload $ record = $ this -> saveFormIntoRecord ( $ data , $ form ) ; $ record -> publishRecursive ( ) ; $ editURL = $ this -> Link ( 'edit' ) ; $ xmlTitle = Convert :: raw2xml ( $ record -> Title ) ; $ link = "<a href=\"{$editURL}\">{$xmlTitle}</a>" ; $ message = _t ( __CLASS__ . '.Published' , 'Published {name} {link}' , [ 'name' => $ record -> i18n_singular_name ( ) , 'link' => $ link ] ) ; $ this -> setFormMessage ( $ form , $ message ) ; return $ this -> redirectAfterSave ( $ isNewRecord ) ; }
Publish this versioned record

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