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
{