cerebrate/libraries/default/OutboxProcessors/TemplateOutoxProcessor.php....

65 lines
1.8 KiB
Plaintext
Raw Permalink Normal View History

<?php
use Cake\ORM\TableRegistry;
require_once(ROOT . DS . 'libraries' . DS . 'default' . DS . 'InboxProcessors' . DS . 'GenericOutboxProcessor.php');
class SCOPE_OutboxProcessor extends GenericOutboxProcessor
{
protected $scope = '~to-be-defined~';
protected $action = 'not-specified'; //overriden when extending
protected $description = ''; // overriden when extending
protected $registeredActions = [
'ACTION'
];
public function __construct($loadFromAction=false) {
parent::__construct($loadFromAction);
}
public function create($requestData)
{
return parent::create($requestData);
}
}
class SCOPE_ACTION_Processor extends ProposalOutboxProcessor implements GenericOutboxProcessorActionI {
public $action = 'ACTION';
protected $description;
public function __construct() {
parent::__construct();
$this->description = __('~to-be-defined~');
$this->Users = TableRegistry::getTableLocator()->get('Users');
}
protected function addValidatorRules($validator)
{
return $validator;
}
public function create($requestData) {
$this->validateRequestData($requestData);
$requestData['title'] = __('~to-be-defined~');
return parent::create($requestData);
}
public function process($id, $requestData, $inboxRequest)
{
$proposalAccepted = false;
$saveResult = [];
if ($proposalAccepted) {
$this->discard($id, $requestData);
}
return $this->genActionResult(
$saveResult,
$proposalAccepted,
$proposalAccepted ? __('success') : __('fail'),
[]
);
}
public function discard($id, $requestData)
{
return parent::discard($id, $requestData);
}
}