public function unPublish(HTTPRequest $request)
    {
        $records = $this->getRecords();
        $response = new HTTPBulkToolsResponse(false, $this->gridField);
        
        try {
            foreach ($records as $record)
            {
                $done = $record->doUnpublish();
                if ($done)
                {
                    $response->addSuccessRecord($record);
                }else{
                    $response->addFailedRecord($record, $done);
                }
            }

            $doneCount = count($response->getSuccessRecords());
            $failCount = count($response->getFailedRecords());
            $message = sprintf(
                'UnPublished %1$d of %2$d records.',
                $doneCount,
                $doneCount + $failCount
            );
            $response->setMessage($message);
        } catch (Exception $ex) {
            $response->setStatusCode(500);
            $response->setMessage($ex->getMessage());
        }

        return $response;
    }
public function unPublish(HTTPRequest $request)
    {
        $records = $this->getRecords();
        $response = new HTTPBulkToolsResponse(false, $this->gridField);
        
        try {
            foreach ($records as $record)
            {
                $done = $record->doUnpublish();
                if ($done)
                {
                    $response->addSuccessRecord($record);
                }else{
                    $response->addFailedRecord($record, $done);
                }
            }

            $doneCount = count($response->getSuccessRecords());
            $failCount = count($response->getFailedRecords());
            $message = sprintf(
                'UnPublished %1$d of %2$d records.',
                $doneCount,
                $doneCount + $failCount
            );
            $response->setMessage($message);
        } catch (Exception $ex) {
            $response->setStatusCode(500);
            $response->setMessage($ex->getMessage());
        }

        return $response;
    }
public function unPublish ( HTTPRequest $ request ) { $ records = $ this -> getRecords ( ) ; $ response = new HTTPBulkToolsResponse ( false , $ this -> gridField ) ; try { foreach ( $ records as $ record ) { $ done = $ record -> doUnpublish ( ) ; if ( $ done ) { $ response -> addSuccessRecord ( $ record ) ; } else { $ response -> addFailedRecord ( $ record , $ done ) ; } } $ doneCount = count ( $ response -> getSuccessRecords ( ) ) ; $ failCount = count ( $ response -> getFailedRecords ( ) ) ; $ message = sprintf ( 'UnPublished %1$d of %2$d records.' , $ doneCount , $ doneCount + $ failCount ) ; $ response -> setMessage ( $ message ) ; } catch ( Exception $ ex ) { $ response -> setStatusCode ( 500 ) ; $ response -> setMessage ( $ ex -> getMessage ( ) ) ; } return $ response ; }
UnPublish the selected records passed from the unPublish bulk action.

@param HTTPRequest $request

@return HTTPBulkToolsResponse
UnPublish the selected records passed from the unPublish bulk action .