Skip to content

Instantly share code, notes, and snippets.

@glye
Created March 21, 2018 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glye/5cefe0e3036ebc09210262be123b5f31 to your computer and use it in GitHub Desktop.
Save glye/5cefe0e3036ebc09210262be123b5f31 to your computer and use it in GitHub Desktop.
Hack for detailed field errors in exception
diff --git a/eZ/Publish/Core/Base/Exceptions/ContentFieldValidationException.php b/eZ/Publish/Core/Base/Exceptions/ContentFieldValidationException.php
index 913462637..f01bc370a 100644
--- a/eZ/Publish/Core/Base/Exceptions/ContentFieldValidationException.php
+++ b/eZ/Publish/Core/Base/Exceptions/ContentFieldValidationException.php
@@ -38,7 +38,13 @@ class ContentFieldValidationException extends APIContentFieldValidationException
public function __construct(array $errors)
{
$this->errors = $errors;
- parent::__construct('Content fields did not validate');
+$str = '';
+foreach($this->getFieldErrors() as $fieldError) {
+ $str .= "\n" . str_replace('%index%',
+ $fieldError['eng-GB'][0]->getTranslatableMessage()->values['index'],
+ $fieldError['eng-GB'][0]->getTranslatableMessage()->message);
+}
+ parent::__construct('Content fields did not validate' . $str);
}
/**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment