2024.11.26 02:41:10

This commit is contained in:
Christian Moser 2024-11-26 02:41:10 +01:00
parent c105fb1b43
commit e78043f6ef
7 changed files with 254 additions and 41 deletions

123
doc/webroot-db.uml.uxf Normal file
View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<diagram program="umlet" version="15.1">
<zoom_level>10</zoom_level>
<element>
<id>UMLClass</id>
<coordinates>
<x>20</x>
<y>20</y>
<w>410</w>
<h>130</h>
</coordinates>
<panel_attributes>_object: WebrootFile_
--
id: Integer
url: string
abspath: string
is_dir: boolean
owner: WebrootUser
permissions: Collection(WebrootFilePermission)
</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>600</x>
<y>10</y>
<w>230</w>
<h>100</h>
</coordinates>
<panel_attributes>_object: WebrootUser_
--
id: Integer
username: string[255]
email: string[255]
roles: string (json-list)
password: string
</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>620</x>
<y>120</y>
<w>280</w>
<h>80</h>
</coordinates>
<panel_attributes>_object: WebrootFilePermission_
--
id: Integer
role: WebrootRole
webrootFile: WebrootFile
is_readable: boolean
is_writeable: boolean
is_dir: boolean
</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>100</x>
<y>200</y>
<w>210</w>
<h>80</h>
</coordinates>
<panel_attributes>_object: WebrootRole_
--
id: Integer
role: string[255]
name: string[255]
description: string
</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>420</x>
<y>10</y>
<w>200</w>
<h>110</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>10.0;90.0;180.0;10.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>420</x>
<y>110</y>
<w>220</w>
<h>40</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>10.0;10.0;200.0;20.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>300</x>
<y>150</y>
<w>340</w>
<h>80</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>320.0;10.0;10.0;60.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>410</x>
<y>20</y>
<w>230</w>
<h>180</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>210.0;160.0;10.0;10.0</additional_attributes>
</element>
</diagram>

View File

@ -0,0 +1,84 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241126013626 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE mydevel_webroot_file (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
owner_id INTEGER NOT NULL,
url CLOB NOT NULL,
abspath CLOB NOT NULL,
CONSTRAINT FK_A7B135127E3C61F9 FOREIGN KEY (owner_id) REFERENCES mydevel_webroot_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE
)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_A7B135127E3C61F9 ON mydevel_webroot_file (owner_id)');
$this->addSql('CREATE TABLE mydevel_webroot_file_permission (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
role_id INTEGER NOT NULL,
webroot_file_id INTEGER NOT NULL,
is_readable BOOLEAN DEFAULT 1 NOT NULL,
is_writeable BOOLEAN DEFAULT 0 NOT NULL,
is_deleteable BOOLEAN DEFAULT 0 NOT NULL,
CONSTRAINT FK_4D56CEFD60322AC FOREIGN KEY (role_id) REFERENCES mydevel_webroot_role (id) NOT DEFERRABLE INITIALLY IMMEDIATE,
CONSTRAINT FK_4D56CEF2800AFC9 FOREIGN KEY (webroot_file_id) REFERENCES mydevel_webroot_file (id) NOT DEFERRABLE INITIALLY IMMEDIATE
)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_4D56CEFD60322AC ON mydevel_webroot_file_permission (role_id)');
$this->addSql('CREATE INDEX IDX_4D56CEF2800AFC9 ON mydevel_webroot_file_permission (webroot_file_id)');
$this->addSql('CREATE TABLE mydevel_webroot_role (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
role VARCHAR(255) NOT NULL,
name VARCHAR(255) NOT NULL,
description VARCHAR(1023) DEFAULT NULL
)');
$this->addSql('CREATE TABLE mydevel_webroot_user (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
username VARCHAR(180) NOT NULL,
roles CLOB NOT NULL --(DC2Type:json)
,
password VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL
)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_A6BDD54BE7927C74 ON mydevel_webroot_user (email)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_USERNAME ON mydevel_webroot_user (username)');
$this->addSql('CREATE TABLE messenger_messages (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
body CLOB NOT NULL,
headers CLOB NOT NULL,
queue_name VARCHAR(190) NOT NULL,
created_at DATETIME NOT NULL --(DC2Type:datetime_immutable)
,
available_at DATETIME NOT NULL --(DC2Type:datetime_immutable)
,
delivered_at DATETIME DEFAULT NULL --(DC2Type:datetime_immutable)
)');
$this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)');
$this->addSql('CREATE INDEX IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)');
$this->addSql('CREATE INDEX IDX_75EA56E016BA31DB ON messenger_messages (delivered_at)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE mydevel_webroot_file');
$this->addSql('DROP TABLE mydevel_webroot_file_permission');
$this->addSql('DROP TABLE mydevel_webroot_role');
$this->addSql('DROP TABLE mydevel_webroot_user');
$this->addSql('DROP TABLE messenger_messages');
}
}

View File

@ -7,7 +7,8 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: WebrootFileRepository::class)]
#[ORM\Entity(repositoryClass: WebrootFileRepository::class,)]
#[ORM\Table(name:'mydevel_webroot_file')]
class WebrootFile
{
#[ORM\Id]
@ -15,21 +16,23 @@ class WebrootFile
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 65535)]
#[ORM\Column(length: 65535,nullable:false)]
private ?string $url = null;
#[ORM\Column(length: 65535)]
#[ORM\Column(length: 65535,nullable:false)]
private ?string $abspath = null;
#[ORM\Column]
private ?bool $is_dir = null;
/**
* @var Collection<int, WebrootPermission>
*/
#[ORM\OneToMany(targetEntity: WebrootPermission::class, mappedBy: 'webrootFile', orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: WebrootFilePermission::class, mappedBy: 'webrootFile', orphanRemoval: true)]
private Collection $permissions;
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
#[ORM\JoinColumn(nullable: false)]
private ?WebrootUser $owner = null;
public function __construct()
{
$this->permissions = new ArrayCollection();
@ -64,18 +67,6 @@ class WebrootFile
return $this;
}
public function isDir(): ?bool
{
return $this->is_dir;
}
public function setDir(bool $is_dir): static
{
$this->is_dir = $is_dir;
return $this;
}
/**
* @return Collection<int, WebrootPermission>
*/
@ -94,7 +85,7 @@ class WebrootFile
return $this;
}
public function removePermission(WebrootPermission $permission): static
public function removePermission(WebrootFilePermission $permission): static
{
if ($this->permissions->removeElement($permission)) {
// set the owning side to null (unless already changed)
@ -105,4 +96,16 @@ class WebrootFile
return $this;
}
public function getOwner(): ?WebrootUser
{
return $this->owner;
}
public function setOwner(WebrootUser $owner): static
{
$this->owner = $owner;
return $this;
}
}

View File

@ -6,7 +6,8 @@ use App\Repository\WebrootPermissionRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: WebrootPermissionRepository::class)]
class WebrootPermission
#[ORM\Table(name:'mydevel_webroot_file_permission')]
class WebrootFilePermission
{
#[ORM\Id]
#[ORM\GeneratedValue]
@ -17,18 +18,15 @@ class WebrootPermission
#[ORM\JoinColumn(nullable: false)]
private ?WebrootRole $role = null;
#[ORM\Column]
#[ORM\Column(options:["default"=>true])]
private ?bool $is_readable = null;
#[ORM\Column]
#[ORM\Column(options:["default"=>false])]
private ?bool $is_writeable = null;
#[ORM\Column]
#[ORM\Column(options:["default"=>false])]
private ?bool $is_deleteable = null;
#[ORM\Column]
private ?bool $is_dir = null;
#[ORM\ManyToOne(inversedBy: 'permissions')]
#[ORM\JoinColumn(nullable: false)]
private ?WebrootFile $webrootFile = null;
@ -86,18 +84,6 @@ class WebrootPermission
return $this;
}
public function isDir(): ?bool
{
return $this->is_dir;
}
public function setDir(bool $is_dir): static
{
$this->is_dir = $is_dir;
return $this;
}
public function getWebrootFile(): ?WebrootFile
{
return $this->webrootFile;

View File

@ -6,6 +6,7 @@ use App\Repository\WebrootRoleRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: WebrootRoleRepository::class)]
#[ORM\Table(name:'mydevel_webroot_role')]
class WebrootRole
{
#[ORM\Id]

View File

@ -9,6 +9,7 @@ use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(repositoryClass: WebrootUserRepository::class)]
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_USERNAME', fields: ['username'])]
#[ORM\Table(name:'mydevel_webroot_user')]
class WebrootUser implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
@ -31,6 +32,9 @@ class WebrootUser implements UserInterface, PasswordAuthenticatedUserInterface
#[ORM\Column]
private ?string $password = null;
#[ORM\Column(length: 255, unique:true)]
private ?string $email = null;
public function getId(): ?int
{
return $this->id;
@ -105,4 +109,16 @@ class WebrootUser implements UserInterface, PasswordAuthenticatedUserInterface
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): static
{
$this->email = $email;
return $this;
}
}

View File

@ -9,11 +9,11 @@ use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<WebrootPermission>
*/
class WebrootPermissionRepository extends ServiceEntityRepository
class WebrootFilePermissionRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, WebrootPermission::class);
parent::__construct($registry, WebrootFilePermission::class);
}
// /**