Fixed orphanRemoval problem with parts collection.

Also ElementPermissionListener was improved, and multiple special cases were unified.
This commit is contained in:
Jan Böhmer 2019-09-17 13:57:40 +02:00
parent 7a9bfdf7f9
commit 3d790db559
4 changed files with 38 additions and 46 deletions

View file

@ -78,9 +78,6 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* Part class.
*
* DONT USE orphanRemoval on properties with ColumnSecurity!! An empty collection will be created as placeholder,
* and the partlots are deleted, even if we want dont want that!
*
* The class properties are split over various traits in directory PartTraits.
* Otherwise this class would be too big, to be maintained.
*
@ -125,7 +122,7 @@ class Part extends AttachmentContainingDBElement
protected $name = '';
/**
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\PartAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=false)
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\PartAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ColumnSecurity(type="collection", prefix="attachments")
* @Assert\Valid()
*/

View file

@ -45,7 +45,7 @@ trait InstockTrait
{
/**
* @var ?PartLot[]|Collection A list of part lots where this part is stored
* @ORM\OneToMany(targetEntity="PartLot", mappedBy="part", cascade={"persist", "remove"}, orphanRemoval=false)
* @ORM\OneToMany(targetEntity="PartLot", mappedBy="part", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
* @ColumnSecurity(type="collection", prefix="lots")
*/

View file

@ -45,7 +45,7 @@ trait OrderTrait
{
/**
* @var Orderdetail[] The details about how and where you can order this part.
* @ORM\OneToMany(targetEntity="App\Entity\PriceInformations\Orderdetail", mappedBy="part", cascade={"persist", "remove"}, orphanRemoval=false)
* @ORM\OneToMany(targetEntity="App\Entity\PriceInformations\Orderdetail", mappedBy="part", cascade={"persist", "remove"}, orphanRemoval=true)
* @Assert\Valid()
* @ColumnSecurity(prefix="orderdetails", type="collection")
*/