chg: [requestProcessors:genericProcessor] Use scope and action to get template path
parent
285061c4c6
commit
14607962f8
|
@ -17,14 +17,19 @@ class GenericRequestProcessor
|
||||||
protected $Inbox;
|
protected $Inbox;
|
||||||
protected $registeredActions = [];
|
protected $registeredActions = [];
|
||||||
protected $validator;
|
protected $validator;
|
||||||
private $processingTemplate = '/genericTemplates/confirm';
|
protected $processingTemplate = '/genericTemplates/confirm';
|
||||||
private $processingTemplatesDirectory = ROOT . '/libraries/default/RequestProcessors/templates';
|
protected $processingTemplatesDirectory = ROOT . '/libraries/default/RequestProcessors/templates';
|
||||||
|
|
||||||
public function __construct($registerActions=false) {
|
public function __construct($registerActions=false) {
|
||||||
$this->Inbox = TableRegistry::getTableLocator()->get('Inbox');
|
$this->Inbox = TableRegistry::getTableLocator()->get('Inbox');
|
||||||
if ($registerActions) {
|
if ($registerActions) {
|
||||||
$this->registerActionInProcessor();
|
$this->registerActionInProcessor();
|
||||||
}
|
}
|
||||||
|
$this->assignProcessingTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function assignProcessingTemplate()
|
||||||
|
{
|
||||||
$processingTemplatePath = $this->getProcessingTemplatePath();
|
$processingTemplatePath = $this->getProcessingTemplatePath();
|
||||||
$file = new File($this->processingTemplatesDirectory . DS . $processingTemplatePath);
|
$file = new File($this->processingTemplatesDirectory . DS . $processingTemplatePath);
|
||||||
if ($file->exists()) {
|
if ($file->exists()) {
|
||||||
|
@ -41,14 +46,16 @@ class GenericRequestProcessor
|
||||||
{
|
{
|
||||||
return $this->scope;
|
return $this->scope;
|
||||||
}
|
}
|
||||||
|
public function getDescription()
|
||||||
private function getProcessingTemplatePath()
|
{
|
||||||
|
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',
|
return sprintf('%s/%s.php',
|
||||||
$class,
|
$this->scope,
|
||||||
$action
|
$this->action
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue