feat: update database relation

This commit is contained in:
Maël Gangloff
2024-07-11 17:01:16 +02:00
parent 2c535f754b
commit 270ffc5cb9
16 changed files with 708 additions and 51 deletions

View File

@@ -12,9 +12,12 @@
"doctrine/doctrine-migrations-bundle": "^3.3",
"doctrine/orm": "^3.2",
"eluceo/ical": "^2.13",
"guzzlehttp/guzzle": "^7.8",
"juanparati/rdap-lib": "^2.1",
"nyholm/psr7": "^1.8",
"phpdocumentor/reflection-docblock": "^5.4",
"phpstan/phpdoc-parser": "^1.29",
"psr/http-client": "^1.0",
"symfony/asset": "7.1.*",
"symfony/asset-mapper": "7.1.*",
"symfony/console": "7.1.*",
@@ -49,7 +52,6 @@
},
"config": {
"allow-plugins": {
"php-http/discovery": true,
"symfony/flex": true,
"symfony/runtime": true
},

449
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "8fc943907edeae7c0a00fb1ed40576e2",
"content-hash": "7ca7ab51341dd737ee39ad655f657dff",
"packages": [
{
"name": "composer/semver",
@@ -1440,6 +1440,331 @@
},
"time": "2023-12-19T19:24:37+00:00"
},
{
"name": "guzzlehttp/guzzle",
"version": "7.8.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "41042bc7ab002487b876a0683fc8dce04ddce104"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/41042bc7ab002487b876a0683fc8dce04ddce104",
"reference": "41042bc7ab002487b876a0683fc8dce04ddce104",
"shasum": ""
},
"require": {
"ext-json": "*",
"guzzlehttp/promises": "^1.5.3 || ^2.0.1",
"guzzlehttp/psr7": "^1.9.1 || ^2.5.1",
"php": "^7.2.5 || ^8.0",
"psr/http-client": "^1.0",
"symfony/deprecation-contracts": "^2.2 || ^3.0"
},
"provide": {
"psr/http-client-implementation": "1.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.2",
"ext-curl": "*",
"php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999",
"php-http/message-factory": "^1.1",
"phpunit/phpunit": "^8.5.36 || ^9.6.15",
"psr/log": "^1.1 || ^2.0 || ^3.0"
},
"suggest": {
"ext-curl": "Required for CURL handler support",
"ext-intl": "Required for Internationalized Domain Name (IDN) support",
"psr/log": "Required for using the Log middleware"
},
"type": "library",
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": false
}
},
"autoload": {
"files": [
"src/functions_include.php"
],
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Jeremy Lindblom",
"email": "jeremeamia@gmail.com",
"homepage": "https://github.com/jeremeamia"
},
{
"name": "George Mponos",
"email": "gmponos@gmail.com",
"homepage": "https://github.com/gmponos"
},
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com",
"homepage": "https://github.com/Nyholm"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com",
"homepage": "https://github.com/sagikazarmark"
},
{
"name": "Tobias Schultze",
"email": "webmaster@tubo-world.de",
"homepage": "https://github.com/Tobion"
}
],
"description": "Guzzle is a PHP HTTP client library",
"keywords": [
"client",
"curl",
"framework",
"http",
"http client",
"psr-18",
"psr-7",
"rest",
"web service"
],
"support": {
"issues": "https://github.com/guzzle/guzzle/issues",
"source": "https://github.com/guzzle/guzzle/tree/7.8.1"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://github.com/Nyholm",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle",
"type": "tidelift"
}
],
"time": "2023-12-03T20:35:24+00:00"
},
{
"name": "guzzlehttp/promises",
"version": "2.0.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "bbff78d96034045e58e13dedd6ad91b5d1253223"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/bbff78d96034045e58e13dedd6ad91b5d1253223",
"reference": "bbff78d96034045e58e13dedd6ad91b5d1253223",
"shasum": ""
},
"require": {
"php": "^7.2.5 || ^8.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.2",
"phpunit/phpunit": "^8.5.36 || ^9.6.15"
},
"type": "library",
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": false
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Promise\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com",
"homepage": "https://github.com/Nyholm"
},
{
"name": "Tobias Schultze",
"email": "webmaster@tubo-world.de",
"homepage": "https://github.com/Tobion"
}
],
"description": "Guzzle promises library",
"keywords": [
"promise"
],
"support": {
"issues": "https://github.com/guzzle/promises/issues",
"source": "https://github.com/guzzle/promises/tree/2.0.2"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://github.com/Nyholm",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises",
"type": "tidelift"
}
],
"time": "2023-12-03T20:19:20+00:00"
},
{
"name": "guzzlehttp/psr7",
"version": "2.6.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/45b30f99ac27b5ca93cb4831afe16285f57b8221",
"reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221",
"shasum": ""
},
"require": {
"php": "^7.2.5 || ^8.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.1 || ^2.0",
"ralouphie/getallheaders": "^3.0"
},
"provide": {
"psr/http-factory-implementation": "1.0",
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.2",
"http-interop/http-factory-tests": "^0.9",
"phpunit/phpunit": "^8.5.36 || ^9.6.15"
},
"suggest": {
"laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
},
"type": "library",
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": false
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Psr7\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "George Mponos",
"email": "gmponos@gmail.com",
"homepage": "https://github.com/gmponos"
},
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com",
"homepage": "https://github.com/Nyholm"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com",
"homepage": "https://github.com/sagikazarmark"
},
{
"name": "Tobias Schultze",
"email": "webmaster@tubo-world.de",
"homepage": "https://github.com/Tobion"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com",
"homepage": "https://sagikazarmark.hu"
}
],
"description": "PSR-7 message implementation that also provides common utility methods",
"keywords": [
"http",
"message",
"psr-7",
"request",
"response",
"stream",
"uri",
"url"
],
"support": {
"issues": "https://github.com/guzzle/psr7/issues",
"source": "https://github.com/guzzle/psr7/tree/2.6.2"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://github.com/Nyholm",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7",
"type": "tidelift"
}
],
"time": "2023-12-03T20:05:35+00:00"
},
{
"name": "juanparati/rdap-lib",
"version": "2.1",
@@ -1588,6 +1913,84 @@
],
"time": "2024-06-28T09:40:51+00:00"
},
{
"name": "nyholm/psr7",
"version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/Nyholm/psr7.git",
"reference": "aa5fc277a4f5508013d571341ade0c3886d4d00e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Nyholm/psr7/zipball/aa5fc277a4f5508013d571341ade0c3886d4d00e",
"reference": "aa5fc277a4f5508013d571341ade0c3886d4d00e",
"shasum": ""
},
"require": {
"php": ">=7.2",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.1 || ^2.0"
},
"provide": {
"php-http/message-factory-implementation": "1.0",
"psr/http-factory-implementation": "1.0",
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"http-interop/http-factory-tests": "^0.9",
"php-http/message-factory": "^1.0",
"php-http/psr7-integration-tests": "^1.0",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.4",
"symfony/error-handler": "^4.4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.8-dev"
}
},
"autoload": {
"psr-4": {
"Nyholm\\Psr7\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com"
},
{
"name": "Martijn van der Ven",
"email": "martijn@vanderven.se"
}
],
"description": "A fast PHP7 implementation of PSR-7",
"homepage": "https://tnyholm.se",
"keywords": [
"psr-17",
"psr-7"
],
"support": {
"issues": "https://github.com/Nyholm/psr7/issues",
"source": "https://github.com/Nyholm/psr7/tree/1.8.1"
},
"funding": [
{
"url": "https://github.com/Zegnat",
"type": "github"
},
{
"url": "https://github.com/nyholm",
"type": "github"
}
],
"time": "2023-11-13T09:31:12+00:00"
},
{
"name": "phpdocumentor/reflection-common",
"version": "2.2.0",
@@ -2276,6 +2679,50 @@
},
"time": "2021-07-14T16:46:02+00:00"
},
{
"name": "ralouphie/getallheaders",
"version": "3.0.3",
"source": {
"type": "git",
"url": "https://github.com/ralouphie/getallheaders.git",
"reference": "120b605dfeb996808c31b6477290a714d356e822"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
"reference": "120b605dfeb996808c31b6477290a714d356e822",
"shasum": ""
},
"require": {
"php": ">=5.6"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.1",
"phpunit/phpunit": "^5 || ^6.5"
},
"type": "library",
"autoload": {
"files": [
"src/getallheaders.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ralph Khattar",
"email": "ralph.khattar@gmail.com"
}
],
"description": "A polyfill for getallheaders.",
"support": {
"issues": "https://github.com/ralouphie/getallheaders/issues",
"source": "https://github.com/ralouphie/getallheaders/tree/develop"
},
"time": "2019-03-08T08:55:37+00:00"
},
{
"name": "symfony/asset",
"version": "v7.1.1",

View File

@@ -0,0 +1,11 @@
services:
# Register nyholm/psr7 services for autowiring with PSR-17 (HTTP factories)
Psr\Http\Message\RequestFactoryInterface: '@nyholm.psr7.psr17_factory'
Psr\Http\Message\ResponseFactoryInterface: '@nyholm.psr7.psr17_factory'
Psr\Http\Message\ServerRequestFactoryInterface: '@nyholm.psr7.psr17_factory'
Psr\Http\Message\StreamFactoryInterface: '@nyholm.psr7.psr17_factory'
Psr\Http\Message\UploadedFileFactoryInterface: '@nyholm.psr7.psr17_factory'
Psr\Http\Message\UriFactoryInterface: '@nyholm.psr7.psr17_factory'
nyholm.psr7.psr17_factory:
class: Nyholm\Psr7\Factory\Psr17Factory

View File

@@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240711120616 extends AbstractMigration
final class Version20240711145906 extends AbstractMigration
{
public function getDescription(): string
{
@@ -22,23 +22,26 @@ final class Version20240711120616 extends AbstractMigration
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE bookmark_domain_list (token VARCHAR(36) NOT NULL, user_id INTEGER NOT NULL, PRIMARY KEY(token), CONSTRAINT FK_F05EDCECA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('CREATE INDEX IDX_F05EDCECA76ED395 ON bookmark_domain_list (user_id)');
$this->addSql('CREATE TABLE domain (ldhname VARCHAR(255) NOT NULL, handle VARCHAR(255) NOT NULL, whois_status VARCHAR(255) NOT NULL, status CLOB NOT NULL --(DC2Type:simple_array)
, PRIMARY KEY(ldhname))');
$this->addSql('CREATE TABLE domain (ldh_name VARCHAR(255) NOT NULL, handle VARCHAR(255) NOT NULL, whois_status VARCHAR(255) NOT NULL, status CLOB NOT NULL --(DC2Type:simple_array)
, PRIMARY KEY(ldh_name, handle))');
$this->addSql('CREATE TABLE domain_entity (domain_id VARCHAR(255) NOT NULL, entity_id VARCHAR(255) NOT NULL, roles CLOB NOT NULL --(DC2Type:simple_array)
, PRIMARY KEY(domain_id, entity_id), CONSTRAINT FK_614B48A1115F0EE5 FOREIGN KEY (domain_id) REFERENCES domain (ldhname) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_614B48A181257D5D FOREIGN KEY (entity_id) REFERENCES entity (handle) NOT DEFERRABLE INITIALLY IMMEDIATE)');
, PRIMARY KEY(domain_id, entity_id), CONSTRAINT FK_614B48A1115F0EE5 FOREIGN KEY (domain_id) REFERENCES domain (handle) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_614B48A181257D5D FOREIGN KEY (entity_id) REFERENCES entity (handle) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('CREATE INDEX IDX_614B48A1115F0EE5 ON domain_entity (domain_id)');
$this->addSql('CREATE INDEX IDX_614B48A181257D5D ON domain_entity (entity_id)');
$this->addSql('CREATE TABLE domain_event ("action" VARCHAR(255) NOT NULL, domain_id VARCHAR(255) NOT NULL, date DATE NOT NULL --(DC2Type:date_immutable)
, PRIMARY KEY("action", domain_id), CONSTRAINT FK_E8D52271115F0EE5 FOREIGN KEY (domain_id) REFERENCES domain (handle) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('CREATE INDEX IDX_E8D52271115F0EE5 ON domain_event (domain_id)');
$this->addSql('CREATE TABLE entity (handle VARCHAR(255) NOT NULL, PRIMARY KEY(handle))');
$this->addSql('CREATE TABLE event ("action" VARCHAR(255) NOT NULL, domain_id VARCHAR(255) NOT NULL, date DATE NOT NULL --(DC2Type:date_immutable)
, PRIMARY KEY("action", domain_id), CONSTRAINT FK_3BAE0AA7115F0EE5 FOREIGN KEY (domain_id) REFERENCES domain (ldhname) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('CREATE INDEX IDX_3BAE0AA7115F0EE5 ON event (domain_id)');
$this->addSql('CREATE TABLE nameserver (handle VARCHAR(255) NOT NULL, ldhname VARCHAR(255) NOT NULL, status CLOB NOT NULL --(DC2Type:simple_array)
$this->addSql('CREATE TABLE nameserver (handle VARCHAR(255) NOT NULL, ldh_name VARCHAR(255) NOT NULL, status CLOB NOT NULL --(DC2Type:simple_array)
, PRIMARY KEY(handle))');
$this->addSql('CREATE TABLE nameserver_entity (nameserver_id VARCHAR(255) NOT NULL, entity_id VARCHAR(255) NOT NULL, roles CLOB NOT NULL --(DC2Type:simple_array)
, status CLOB NOT NULL --(DC2Type:simple_array)
, PRIMARY KEY(nameserver_id, entity_id), CONSTRAINT FK_A269AFB41A555619 FOREIGN KEY (nameserver_id) REFERENCES nameserver (handle) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_A269AFB481257D5D FOREIGN KEY (entity_id) REFERENCES entity (handle) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('CREATE INDEX IDX_A269AFB41A555619 ON nameserver_entity (nameserver_id)');
$this->addSql('CREATE INDEX IDX_A269AFB481257D5D ON nameserver_entity (entity_id)');
$this->addSql('CREATE TABLE nameserver_event ("action" VARCHAR(255) NOT NULL, nameserver_id VARCHAR(255) NOT NULL, date DATETIME NOT NULL --(DC2Type:datetime_immutable)
, PRIMARY KEY(nameserver_id, "action"), CONSTRAINT FK_C6BC968C1A555619 FOREIGN KEY (nameserver_id) REFERENCES nameserver (handle) NOT DEFERRABLE INITIALLY IMMEDIATE)');
$this->addSql('CREATE INDEX IDX_C6BC968C1A555619 ON nameserver_event (nameserver_id)');
$this->addSql('CREATE TABLE user (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, email VARCHAR(180) NOT NULL, roles CLOB NOT NULL --(DC2Type:json)
, password VARCHAR(255) NOT NULL)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_EMAIL ON user (email)');
@@ -57,10 +60,11 @@ final class Version20240711120616 extends AbstractMigration
$this->addSql('DROP TABLE bookmark_domain_list');
$this->addSql('DROP TABLE domain');
$this->addSql('DROP TABLE domain_entity');
$this->addSql('DROP TABLE domain_event');
$this->addSql('DROP TABLE entity');
$this->addSql('DROP TABLE event');
$this->addSql('DROP TABLE nameserver');
$this->addSql('DROP TABLE nameserver_entity');
$this->addSql('DROP TABLE nameserver_event');
$this->addSql('DROP TABLE user');
$this->addSql('DROP TABLE messenger_messages');
}

View File

@@ -0,0 +1,8 @@
<?php
namespace App\Controller;
class TestController
{
}

View File

@@ -15,14 +15,14 @@ class BookmarkDomainList
#[ORM\Column(length: 36)]
private string $token;
#[ORM\ManyToOne(inversedBy: 'bookmarkDomainLists')]
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'bookmarkDomainLists')]
#[ORM\JoinColumn(nullable: false)]
private ?User $user = null;
/**
* @var Collection<int, Domain>
*/
#[ORM\ManyToMany(targetEntity: Domain::class, mappedBy: 'ldhname')]
#[ORM\ManyToMany(targetEntity: Domain::class, mappedBy: 'handle')]
private Collection $domains;
public function __construct()

View File

@@ -14,15 +14,16 @@ class Domain
{
#[ORM\Id]
#[ORM\Column(length: 255)]
private ?string $ldhname = null;
private ?string $ldhName = null;
#[ORM\Id]
#[ORM\Column(length: 255)]
private ?string $handle = null;
/**
* @var Collection<int, Event>
* @var Collection<int, DomainEvent>
*/
#[ORM\OneToMany(targetEntity: Event::class, mappedBy: 'domain', orphanRemoval: true)]
#[ORM\OneToMany(targetEntity: DomainEvent::class, mappedBy: 'domain', orphanRemoval: true)]
private Collection $events;
/**
@@ -37,20 +38,27 @@ class Domain
#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainStatus::class)]
private array $status = [];
/**
* @var Collection<int, Nameserver>
*/
#[ORM\ManyToMany(targetEntity: Nameserver::class, mappedBy: 'handle')]
private Collection $nameservers;
public function __construct()
{
$this->events = new ArrayCollection();
$this->domainEntities = new ArrayCollection();
$this->nameservers = new ArrayCollection();
}
public function getLdhname(): ?string
public function getLdhName(): ?string
{
return $this->ldhname;
return $this->ldhName;
}
public function setLdhname(string $ldhname): static
public function setLdhName(string $ldhName): static
{
$this->ldhname = $ldhname;
$this->ldhName = $ldhName;
return $this;
}
@@ -68,14 +76,14 @@ class Domain
}
/**
* @return Collection<int, Event>
* @return Collection<int, DomainEvent>
*/
public function getEvents(): Collection
{
return $this->events;
}
public function addEvent(Event $event): static
public function addEvent(DomainEvent $event): static
{
if (!$this->events->contains($event)) {
$this->events->add($event);
@@ -85,7 +93,7 @@ class Domain
return $this;
}
public function removeEvent(Event $event): static
public function removeEvent(DomainEvent $event): static
{
if ($this->events->removeElement($event)) {
// set the owning side to null (unless already changed)
@@ -153,4 +161,28 @@ class Domain
return $this;
}
/**
* @return Collection<int, Nameserver>
*/
public function getNameservers(): Collection
{
return $this->nameservers;
}
public function addNameserver(Nameserver $nameserver): static
{
if (!$this->nameservers->contains($nameserver)) {
$this->nameservers->add($nameserver);
}
return $this;
}
public function removeNameserver(Nameserver $nameserver): static
{
$this->nameservers->removeElement($nameserver);
return $this;
}
}

View File

@@ -11,12 +11,12 @@ use Doctrine\ORM\Mapping as ORM;
class DomainEntity
{
#[ORM\Id]
#[ORM\ManyToOne(inversedBy: 'domainEntities')]
#[ORM\JoinColumn(referencedColumnName: 'ldhname', nullable: false)]
#[ORM\ManyToOne(targetEntity: Domain::class, inversedBy: 'domainEntities')]
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
private ?Domain $domain = null;
#[ORM\Id]
#[ORM\ManyToOne(inversedBy: 'domainEntities')]
#[ORM\ManyToOne(targetEntity: Entity::class, inversedBy: 'domainEntities')]
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
private ?Entity $entity = null;

View File

@@ -2,31 +2,32 @@
namespace App\Entity;
use App\Repository\EventRepository;
use App\Config\EventAction;
use App\Repository\DomainEventRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: EventRepository::class)]
class Event
#[ORM\Entity(repositoryClass: DomainEventRepository::class)]
class DomainEvent
{
#[ORM\Id]
#[ORM\Column(length: 255)]
private ?string $action = null;
#[ORM\Column(enumType: EventAction::class)]
private ?EventAction $action = null;
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
private ?\DateTimeImmutable $date = null;
#[ORM\Id]
#[ORM\ManyToOne(inversedBy: 'events')]
#[ORM\JoinColumn(referencedColumnName: 'ldhname', nullable: false)]
#[ORM\ManyToOne(targetEntity: Domain::class, inversedBy: 'events')]
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
private ?Domain $domain = null;
public function getAction(): ?string
public function getAction(): ?EventAction
{
return $this->action;
}
public function setAction(string $action): static
public function setAction(EventAction $action): static
{
$this->action = $action;

View File

@@ -17,7 +17,7 @@ class Nameserver
private ?string $handle = null;
#[ORM\Column(length: 255)]
private ?string $ldhname = null;
private ?string $ldhName = null;
/**
* @var Collection<int, NameserverEntity>
@@ -28,9 +28,16 @@ class Nameserver
#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainStatus::class)]
private array $status = [];
/**
* @var Collection<int, NameserverEvent>
*/
#[ORM\OneToMany(targetEntity: NameserverEvent::class, mappedBy: 'nameserver', orphanRemoval: true)]
private Collection $nameserverEvents;
public function __construct()
{
$this->nameserverEntities = new ArrayCollection();
$this->nameserverEvents = new ArrayCollection();
}
public function getHandle(): ?string
@@ -45,14 +52,14 @@ class Nameserver
return $this;
}
public function getLdhname(): ?string
public function getLdhName(): ?string
{
return $this->ldhname;
return $this->ldhName;
}
public function setLdhname(string $ldhname): static
public function setLdhName(string $ldhName): static
{
$this->ldhname = $ldhname;
$this->ldhName = $ldhName;
return $this;
}
@@ -102,4 +109,34 @@ class Nameserver
return $this;
}
/**
* @return Collection<int, NameserverEvent>
*/
public function getNameserverEvents(): Collection
{
return $this->nameserverEvents;
}
public function addNameserverEvent(NameserverEvent $nameserverEvent): static
{
if (!$this->nameserverEvents->contains($nameserverEvent)) {
$this->nameserverEvents->add($nameserverEvent);
$nameserverEvent->setNameserver($this);
}
return $this;
}
public function removeNameserverEvent(NameserverEvent $nameserverEvent): static
{
if ($this->nameserverEvents->removeElement($nameserverEvent)) {
// set the owning side to null (unless already changed)
if ($nameserverEvent->getNameserver() === $this) {
$nameserverEvent->setNameserver(null);
}
}
return $this;
}
}

View File

@@ -12,12 +12,12 @@ use Doctrine\ORM\Mapping as ORM;
class NameserverEntity
{
#[ORM\Id]
#[ORM\ManyToOne(inversedBy: 'nameserverEntities')]
#[ORM\ManyToOne(targetEntity: Nameserver::class, inversedBy: 'nameserverEntities')]
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
private ?Nameserver $nameserver = null;
#[ORM\Id]
#[ORM\ManyToOne(inversedBy: 'nameserverEntities')]
#[ORM\ManyToOne(targetEntity: Entity::class, inversedBy: 'nameserverEntities')]
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
private ?Entity $entity = null;

View File

@@ -0,0 +1,59 @@
<?php
namespace App\Entity;
use App\Config\EventAction;
use App\Repository\NameserverEventRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: NameserverEventRepository::class)]
class NameserverEvent
{
#[ORM\Column]
private ?\DateTimeImmutable $date = null;
#[ORM\Id]
#[ORM\ManyToOne(inversedBy: 'nameserverEvents')]
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
private ?Nameserver $nameserver = null;
#[ORM\Id]
#[ORM\Column(enumType: EventAction::class)]
private ?EventAction $action = null;
public function getDate(): ?\DateTimeImmutable
{
return $this->date;
}
public function setDate(\DateTimeImmutable $date): static
{
$this->date = $date;
return $this;
}
public function getNameserver(): ?Nameserver
{
return $this->nameserver;
}
public function setNameserver(?Nameserver $nameserver): static
{
$this->nameserver = $nameserver;
return $this;
}
public function getAction(): ?EventAction
{
return $this->action;
}
public function setAction(EventAction $action): static
{
$this->action = $action;
return $this;
}
}

View File

@@ -22,13 +22,13 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
private ?string $email = null;
/**
* @var list<string> The user roles
* @var array The user roles
*/
#[ORM\Column]
private array $roles = [];
/**
* @var string The hashed password
* @var string|null The hashed password
*/
#[ORM\Column]
private ?string $password = null;
@@ -86,7 +86,8 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
}
/**
* @param list<string> $roles
* @param array $roles
* @return User
*/
public function setRoles(array $roles): static
{

View File

@@ -2,22 +2,22 @@
namespace App\Repository;
use App\Entity\Event;
use App\Entity\DomainEvent;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Event>
* @extends ServiceEntityRepository<DomainEvent>
*/
class EventRepository extends ServiceEntityRepository
class DomainEventRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Event::class);
parent::__construct($registry, DomainEvent::class);
}
// /**
// * @return Event[] Returns an array of Event objects
// * @return DomainEvent[] Returns an array of DomainEvent objects
// */
// public function findByExampleField($value): array
// {
@@ -31,7 +31,7 @@ class EventRepository extends ServiceEntityRepository
// ;
// }
// public function findOneBySomeField($value): ?Event
// public function findOneBySomeField($value): ?DomainEvent
// {
// return $this->createQueryBuilder('e')
// ->andWhere('e.exampleField = :val')

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Repository;
use App\Entity\NameserverEvent;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<NameserverEvent>
*/
class NameserverEventRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, NameserverEvent::class);
}
// /**
// * @return NameserverEvent[] Returns an array of NameserverEvent objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('n')
// ->andWhere('n.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('n.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?NameserverEvent
// {
// return $this->createQueryBuilder('n')
// ->andWhere('n.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@@ -26,6 +26,18 @@
"migrations/.gitignore"
]
},
"nyholm/psr7": {
"version": "1.8",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "1.0",
"ref": "4a8c0345442dcca1d8a2c65633dcf0285dd5a5a2"
},
"files": [
"config/packages/nyholm_psr7.yaml"
]
},
"phpunit/phpunit": {
"version": "9.6",
"recipe": {