Local action traits
<?php
namespace DeepWebSolutions\Plugins\MyTestPlugin\Actions;
use DeepWebSolutions\Framework\Foundations\Actions\OutputtableInterface;
use DeepWebSolutions\Framework\Foundations\Actions\Outputtable\OutputFailureException;
use DeepWebSolutions\Framework\Foundations\Actions\Outputtable\OutputLocalTrait;
class MyOutput implements OutputtableInterface {
use OutputLocalTrait; // USE THIS
protected bool $success;
public function __construct( bool $success ) {
$this->success = $success;
}
protected function output_local(): ?OutputFailureException {
if ( true === $this->success ) {
return null;
} else {
return new OutputFailureException( 'Local output failed for some reason' );
}
}
}
$my_output = new MyOutput( true );
$my_output->output(); // equals null
$my_output = new MyOutput( false );
$my_output->output()->getMessage(); // equals 'Local output failed for some reason'
Last updated