: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
namespace NinjaForms\Includes\Abstracts;
use NinjaForms\Includes\Contracts\SubmissionHandler as ContractSubmissionHandler;
use NinjaForms\Includes\Entities\SingleSubmission;
use NinjaForms\Includes\Entities\SubmissionExtraHandlerResponse;
* Abstract class implementing SubmissionHandler
* Child class sets responseType, download, blobType, filename
* $this->responseType can be 'none' or 'download'. 'none' means that some
* action is performed but there is no returned data to be downloaded.
* 'download' means that there is data to be downloaded, such as a PDF or CSV.
* $this->download is the data that is to be downloaded
* $this->blobType is the application type of the download, instructing the
* fetch command the format of the downloadable data
* $this->result is a summary message for the request, usually 'ok' or a
abstract class SubmissionHandler implements ContractSubmissionHandler
* camelCase slug of class
* Response can be 'none' or `download`
protected $responseType = 'none';
* Result of request (usu. 'ok' or failure message)
* Base 64 encoded downloadable string
protected $download = '';
* Application type of download (for constructing download)
protected $blobType = '';
* Filename of the download, including file extension
protected $filename = '';
* Label for single row command
* Registers command to export single submission as PDF
public function __construct()
\add_filter('nf_react_table_submission_handlers', [$this, 'addSubmissionHandler'], 10, 2);
* Construct translatable label property
abstract protected function constructLabel(): void;
public function addSubmissionHandler(array $handlerCollection, ?SingleSubmission $singleSubmission): array
if(!is_null($singleSubmission) && $this->doesAddHandler($singleSubmission)){
$handlerCollection[$this->getSlug()] =
'handlerClassName' => $this->getHandlerClassName(),
'handlerLabel' => $this->getLabel()
return $handlerCollection;
* Determine if handler is added to submission row
* @param SingleSubmission $singleSubmission
abstract protected function doesAddHandler(SingleSubmission $singleSubmission): bool;
* Perform extra handler action on a single submission
* @param SingleSubmission $singleSubmission
public function handle(SingleSubmission $singleSubmission): array
$this->handleSubmission($singleSubmission);
$returnArray = (SubmissionExtraHandlerResponse::fromArray([
'responseType' => $this->responseType,
'download' => $this->download,
'blobType' => $this->blobType,
'result' => $this->result,
'filename' => $this->filename
* Perform functionality on submission, update properties for return
* @param SingleSubmission $singleSubmission
abstract protected function handleSubmission(SingleSubmission $singleSubmission):void;
* Returns payload for download
public function getDownload(): string
* Return an identifying slug for the handler
public function getSlug(): string
* Return a label for the handler
public function getLabel(): string
* Return class name of SubmissionHandler
abstract public function getHandlerClassName(): string;