2021-03-18 15:17:39 +01:00
|
|
|
<?php
|
|
|
|
use Cake\ORM\TableRegistry;
|
|
|
|
|
2021-06-18 11:09:19 +02:00
|
|
|
require_once(ROOT . DS . 'libraries' . DS . 'default' . DS . 'InboxProcessors' . DS . 'GenericInboxProcessor.php');
|
2021-03-18 15:17:39 +01:00
|
|
|
|
2021-06-18 11:09:19 +02:00
|
|
|
class BroodInboxProcessor extends GenericInboxProcessor
|
2021-03-18 15:17:39 +01:00
|
|
|
{
|
|
|
|
protected $scope = 'Brood';
|
|
|
|
protected $action = 'not-specified'; //overriden when extending
|
|
|
|
protected $description = ''; // overriden when extending
|
|
|
|
protected $registeredActions = [
|
|
|
|
'ToolInterconnection',
|
|
|
|
];
|
|
|
|
|
|
|
|
public function __construct($loadFromAction=false) {
|
|
|
|
parent::__construct($loadFromAction);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function create($requestData)
|
|
|
|
{
|
|
|
|
return parent::create($requestData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-21 14:30:32 +02:00
|
|
|
class ToolInterconnectionProcessor extends BroodInboxProcessor implements GenericInboxProcessorActionI {
|
2021-03-18 15:17:39 +01:00
|
|
|
public $action = 'ToolInterconnection';
|
|
|
|
protected $description;
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
parent::__construct();
|
|
|
|
$this->description = __('Handle tool interconnection request from other cerebrate instance');
|
|
|
|
$this->Broods = TableRegistry::getTableLocator()->get('Broods');
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function addValidatorRules($validator)
|
|
|
|
{
|
|
|
|
return $validator;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function create($requestData) {
|
|
|
|
$this->validateRequestData($requestData);
|
|
|
|
$requestData['title'] = __('Cerebrate instance {0} requested interconnection for tool {1}', 'Insert brood name', 'Insert tool name');
|
|
|
|
return parent::create($requestData);
|
|
|
|
}
|
|
|
|
|
2021-06-14 13:25:49 +02:00
|
|
|
public function process($id, $requestData, $inboxRequest)
|
2021-03-18 15:17:39 +01:00
|
|
|
{
|
|
|
|
$connectionSuccessfull = false;
|
|
|
|
$interConnectionResult = [];
|
|
|
|
if ($connectionSuccessfull) {
|
|
|
|
$this->discard($id, $requestData);
|
|
|
|
}
|
|
|
|
return $this->genActionResult(
|
|
|
|
$interConnectionResult,
|
|
|
|
$connectionSuccessfull,
|
|
|
|
$connectionSuccessfull ? __('Interconnection for `{0}` created', 'Insert tool name') : __('Could interconnect tool `{0}`.', 'Insert tool name'),
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function discard($id, $requestData)
|
|
|
|
{
|
|
|
|
return parent::discard($id, $requestData);
|
|
|
|
}
|
|
|
|
}
|