fix: [outboxProcessor:generic] Added support of severity

pull/121/head
Sami Mokaddem 2022-11-15 11:13:40 +01:00
parent be7293a5a4
commit 1626037239
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 13 additions and 2 deletions

View File

@ -20,9 +20,14 @@ class GenericOutboxProcessor
protected $validator;
protected $processingTemplate = '/genericTemplates/confirm';
protected $processingTemplatesDirectory = ROOT . '/libraries/default/OutboxProcessors/templates';
protected $defaultSeverity;
protected $severity;
public function __construct($registerActions=false) {
$this->Outbox = TableRegistry::getTableLocator()->get('Outbox');
$this->Inbox = TableRegistry::getTableLocator()->get('Inbox');
$this->defaultSeverity = $this->Inbox::SEVERITY_INFO;
if ($registerActions) {
$this->registerActionInProcessor();
}
@ -55,6 +60,10 @@ class GenericOutboxProcessor
{
return $this->description ?? '';
}
public function getSeverity()
{
return $this->severity ?? $this->defaultSeverity;
}
protected function getProcessingTemplatePath()
{
@ -77,8 +86,9 @@ class GenericOutboxProcessor
$builder = new ViewBuilder();
$builder->disableAutoLayout()
->setClassName('Monad')
->setTemplate($processingTemplate);
$view = $builder->build($viewVariables);
->setTemplate($processingTemplate)
->setVars($viewVariables);
$view = $builder->build();
$view->setRequest($serverRequest);
return $view->render();
}
@ -193,6 +203,7 @@ class GenericOutboxProcessor
$user_id = Router::getRequest()->getSession()->read('Auth.id');
$requestData['scope'] = $this->scope;
$requestData['action'] = $this->action;
$requestData['severity'] = $this->getSeverity();
$requestData['user_id'] = $user_id;
$request = $this->generateRequest($requestData);
$savedRequest = $this->Outbox->createEntry($request);