mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-26 03:38:47 +02:00
Make PermissionData an embeddable so doctrine can properly track changes to the data array
This commit is contained in:
parent
687ee80255
commit
59ddf91527
5 changed files with 53 additions and 47 deletions
|
@ -2,6 +2,14 @@
|
|||
|
||||
namespace App\Entity\UserSystem;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* This class is used to store the permissions of a user.
|
||||
* This has to be an embeddable or otherwise doctrine could not track the changes of the underlying data array (which is serialized to JSON in the database)
|
||||
*
|
||||
* @ORM\Embeddable()
|
||||
*/
|
||||
final class PermissionData implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
|
@ -17,8 +25,9 @@ final class PermissionData implements \JsonSerializable
|
|||
* permission => [
|
||||
* operation => value,
|
||||
* ]
|
||||
* @ORM\Column(type="json", name="data")
|
||||
*/
|
||||
protected array $data = [];
|
||||
protected ?array $data = [];
|
||||
|
||||
/**
|
||||
* Creates a new Permission Data Instance using the given data.
|
||||
|
@ -91,6 +100,11 @@ final class PermissionData implements \JsonSerializable
|
|||
return new self($data);
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->data = $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an JSON encodable representation of this object.
|
||||
* @return array|mixed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue