Skip to content

Commit

Permalink
EZP-28902: Creating a user with existing username results in Internal…
Browse files Browse the repository at this point in the history
… Server Error. (#224)
  • Loading branch information
mikadamczyk authored and Łukasz Serwatka committed Mar 19, 2018
1 parent 740baf8 commit ae9c470
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
5 changes: 5 additions & 0 deletions bundle/Resources/translations/validators.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
</header>
<body>
<trans-unit id="c10b0c448f6442d0a67d6787f458e09c823d79f7" resname="The user login '%login%' is used by another user. You must enter a unique login.">
<source>The user login '%login%' is used by another user. You must enter a unique login.</source>
<target state="new">The user login '%login%' is used by another user. You must enter a unique login.</target>
<note>key: The user login '%login%' is used by another user. You must enter a unique login.</note>
</trans-unit>
<trans-unit id="facbff93edf91393ba1bb60212f504d35beae555" resname="ez.content_type.descriptions">
<source>Content type description cannot exceed 255 characters.</source>
<target>Content type description cannot exceed 255 characters.</target>
Expand Down
3 changes: 2 additions & 1 deletion lib/Validator/Constraints/FieldValueValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use eZ\Publish\Core\FieldType\ValidationError;
use EzSystems\RepositoryForms\Data\Content\FieldData;
use EzSystems\RepositoryForms\Data\FieldDefinitionData;
use Symfony\Component\Validator\Util\PropertyPath;
use Symfony\Component\Validator\Constraint;

/**
Expand Down Expand Up @@ -96,6 +97,6 @@ protected function getFieldTypeIdentifier(ValueObject $value)

protected function generatePropertyPath($errorIndex, $errorTarget)
{
return 'value';
return PropertyPath::append('value', $errorTarget);
}
}
30 changes: 30 additions & 0 deletions lib/Validator/Constraints/FieldValueValidatorMessages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace EzSystems\RepositoryForms\Validator\Constraints;

use JMS\TranslationBundle\Translation\TranslationContainerInterface;
use JMS\TranslationBundle\Model\Message;

/**
* This class holds translation messages which comes from kernel as ValidationError messages.
* It allows JMSTranslationBundle to extracting those messages.
*/
class FieldValueValidatorMessages implements TranslationContainerInterface
{
/**
* Returns an array of messages.
*
* @return Message[]
*/
public static function getTranslationMessages(): array
{
return [
new Message("The user login '%login%' is used by another user. You must enter a unique login.", 'validators'),
];
}
}

0 comments on commit ae9c470

Please sign in to comment.