diff --git a/src/Entity/StructuralDBElement.php b/src/Entity/StructuralDBElement.php index d1fa2063..d3e9e0c1 100644 --- a/src/Entity/StructuralDBElement.php +++ b/src/Entity/StructuralDBElement.php @@ -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 { diff --git a/translations/validators.de.xlf b/translations/validators.de.xlf new file mode 100644 index 00000000..315ee38f --- /dev/null +++ b/translations/validators.de.xlf @@ -0,0 +1,11 @@ + + + + + + structural.entity.unique_name + Es kann auf jeder Ebene nur ein Objekt mit dem gleichem Namen geben! + + + +