Skip to content

Commit

Permalink
Better error messages; reduce the nr of tags managed by the location …
Browse files Browse the repository at this point in the history
…resolver
  • Loading branch information
gggeek committed Nov 20, 2016
1 parent f8c48e3 commit cb658d4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
21 changes: 17 additions & 4 deletions Core/MigrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,24 +302,32 @@ protected function getFullExceptionMessage(\Exception $e)
$message = $e->getMessage();
if (is_a($e, '\eZ\Publish\API\Repository\Exceptions\ContentTypeFieldDefinitionValidationException') ||
is_a($e, '\eZ\Publish\API\Repository\Exceptions\ContentTypeFieldValidationException') ||
is_a($e, '\eZ\Publish\API\Repository\Exceptions\LimitationValidationException')
is_a($e, '\eZ\Publish\API\Repository\Exceptions\LimitationValidationException') ||
is_a($e, '\eZ\Publish\Core\Base\Exceptions\ContentFieldValidationException')
) {
if (is_a($e, '\eZ\Publish\API\Repository\Exceptions\LimitationValidationException')) {
$errorsArray = $e->getLimitationErrors();
if ($errorsArray == null) {
return $message;
}
$errorsArray = array($errorsArray);
} else if (is_a($e, '\eZ\Publish\Core\Base\Exceptions\ContentFieldValidationException')) {
foreach ($e->getFieldErrors() as $limitationError) {
// we get the 1st language
$errorsArray[] = reset($limitationError);
}
} else {
$errorsArray = $e->getFieldErrors();
}

foreach ($errorsArray as $errors) {

// sometimes error arrays are 2-level deep, sometimes 1...
if (!is_array($errors)) {
$errors = array($errors);
}
foreach ($errors as $error) {
/// @todo find out what is the proper eZ way of getting a translated message for these errors
$translatableMessage = $error->getTranslatableMessage();
if (is_a($e, 'eZ\Publish\API\Repository\Values\Translation\Plural')) {
if (is_a($translatableMessage, '\eZ\Publish\API\Repository\Values\Translation\Plural')) {
$msgText = $translatableMessage->plural;
} else {
$msgText = $translatableMessage->message;
Expand All @@ -329,6 +337,11 @@ protected function getFullExceptionMessage(\Exception $e)
}
}
}

while (($e = $e->getPrevious()) != null) {
$message .= "\n" . $e->getMessage();
}

return $message;
}
}
4 changes: 2 additions & 2 deletions Core/ReferenceResolver/LocationResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class LocationResolver extends AbstractResolver
/**
* Defines the prefix for all reference identifier strings in definitions
*/
protected $referencePrefixes = array('location_remote_id:', 'location:');
protected $referencePrefixes = array('location:'/*, 'location_remote_id:'*/);

protected $repository;

Expand All @@ -37,7 +37,7 @@ public function getReferenceValue($stringIdentifier)
switch($ref['prefix']) {
/// @deprecated !!!
case 'location:':
case 'location_remote_id:':
//case 'location_remote_id:':
return $this->repository->getLocationService()->loadLocationByRemoteId($ref['identifier'])->id;
//case 'location_id::':
// return $this->repository->getLocationService()->loadLocation($ref['identifier']);
Expand Down
8 changes: 8 additions & 0 deletions WHATSNEW.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Version 2.5.1
=============

* Fix: bring back the support for resolving 'location:<remote_id>' tags as was done in version 1.X of the extension

* New: improve error messages pertaining to content creation/update


Version 2.5
===========

Expand Down

0 comments on commit cb658d4

Please sign in to comment.