Enforce unique names per level on structural elements.

This commit is contained in:
Jan Böhmer 2019-04-06 18:45:26 +02:00
parent 7c43feefbe
commit 09eb3c226a
2 changed files with 14 additions and 0 deletions

View file

@ -26,6 +26,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\PersistentCollection;
use App\Validator\Constraints\NoneOfItsChildren;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* All elements with the fields "id", "name" and "parent_id" (at least).
@ -37,6 +38,8 @@ use App\Validator\Constraints\NoneOfItsChildren;
* an attribute of a root element, you will get an exception!
*
* @ORM\MappedSuperclass(repositoryClass="App\Repository\StructuralDBElementRepository")
*
* @UniqueEntity(fields={"name", "parent"}, ignoreNull=false, message="structural.entity.unique_name")
*/
abstract class StructuralDBElement extends AttachmentContainingDBElement
{

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="en" trgLang="de">
<file id="validators.de">
<unit id="VJHTkxx" name="structural.entity.unique_name">
<segment>
<source>structural.entity.unique_name</source>
<target>Es kann auf jeder Ebene nur ein Objekt mit dem gleichem Namen geben!</target>
</segment>
</unit>
</file>
</xliff>