chg: [requestProcessors:genericProcessor] Use scope and action to get template path

pull/59/head
mokaddem 2021-06-12 12:11:23 +02:00
parent 285061c4c6
commit 14607962f8
1 changed files with 15 additions and 8 deletions

View File

@ -17,14 +17,19 @@ class GenericRequestProcessor
protected $Inbox;
protected $registeredActions = [];
protected $validator;
private $processingTemplate = '/genericTemplates/confirm';
private $processingTemplatesDirectory = ROOT . '/libraries/default/RequestProcessors/templates';
protected $processingTemplate = '/genericTemplates/confirm';
protected $processingTemplatesDirectory = ROOT . '/libraries/default/RequestProcessors/templates';
public function __construct($registerActions=false) {
$this->Inbox = TableRegistry::getTableLocator()->get('Inbox');
if ($registerActions) {
$this->registerActionInProcessor();
}
$this->assignProcessingTemplate();
}
private function assignProcessingTemplate()
{
$processingTemplatePath = $this->getProcessingTemplatePath();
$file = new File($this->processingTemplatesDirectory . DS . $processingTemplatePath);
if ($file->exists()) {
@ -41,14 +46,16 @@ class GenericRequestProcessor
{
return $this->scope;
}
private function getProcessingTemplatePath()
public function getDescription()
{
return $this->description ?? '';
}
protected function getProcessingTemplatePath()
{
$class = str_replace('RequestProcessor', '', get_parent_class($this));
$action = strtolower(str_replace('Processor', '', get_class($this)));
return sprintf('%s/%s.php',
$class,
$action
$this->scope,
$this->action
);
}