[TASK] Improve error and config handling
This commit is contained in:
@@ -123,6 +123,11 @@ class ActionController extends BaseController
|
||||
*/
|
||||
protected $uriBuilder = null;
|
||||
|
||||
/**
|
||||
* general config
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* propertyMappginConfigrtationBuolder
|
||||
*/
|
||||
@@ -176,6 +181,9 @@ class ActionController extends BaseController
|
||||
*/
|
||||
public function initializeAction()
|
||||
{
|
||||
$this->config = GeneralUtility::removeDotsFromTS(
|
||||
$GLOBALS['TSFE']->config['config']
|
||||
);
|
||||
$this->pageType = GeneralUtility::_GP('type');
|
||||
if (!is_numeric($this->pageType)) {
|
||||
$this->pageType = 0;
|
||||
@@ -209,6 +217,16 @@ class ActionController extends BaseController
|
||||
$this->arguments->addNewArgument('submit', 'string', false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns an instance of uribuilder
|
||||
*/
|
||||
public function getUriBuilder()
|
||||
{
|
||||
return $this->objectManager->get(
|
||||
UriBuilder::class
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* shortcut
|
||||
*
|
||||
@@ -376,15 +394,21 @@ class ActionController extends BaseController
|
||||
/**
|
||||
* function to add validation error manually in the controller
|
||||
*/
|
||||
protected function addValidationError($field, $keyword) {
|
||||
protected function addValidationError(
|
||||
$field, $keyword, $overwrite = false
|
||||
) {
|
||||
$this->responseStatus = [400 => 'validationError'];
|
||||
$this->errors[$field] = [
|
||||
'keyword' => $keyword,
|
||||
];
|
||||
$this->errorLabels[$field] = $this->getErrorLabel(
|
||||
$field,
|
||||
$keyword
|
||||
);
|
||||
if (!array_key_exists($field, $this->errors)
|
||||
|| $overwrite == true
|
||||
) {
|
||||
$this->errors[$field] = [
|
||||
'keyword' => $keyword,
|
||||
];
|
||||
$this->errorLabels[$field] = $this->getErrorLabel(
|
||||
$field,
|
||||
$keyword
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user