Skip to content

Commit

Permalink
Domain: use attributes for entity mapping, remove base entity
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Dec 6, 2024
1 parent c24752e commit 4964e84
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 51 deletions.
25 changes: 16 additions & 9 deletions app/Domain/Database/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@

namespace App\Domain\Database;

use App\Model\Database\Entity\AbstractEntity;
use DateTime;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity(repositoryClass="App\Domain\Database\UserRepository")
* @ORM\Table(name="`user`")
*/
class User extends AbstractEntity
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\Table(name: '`user`')]
class User
{

/** @ORM\Column(type="string") */
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;

#[ORM\Column(type: 'string')]
private string $username;

/** @ORM\Column(type="datetime") */
#[ORM\Column(type: 'datetime')]
private DateTime $createdAt;

/** @ORM\Column(type="datetime", nullable=true) */
#[ORM\Column(type: 'datetime', nullable: true)]
private ?DateTime $updatedAt = null;

public function __construct(string $username)
Expand All @@ -28,6 +30,11 @@ public function __construct(string $username)
$this->createdAt = new DateTime();
}

public function getId(): int
{
return $this->id;
}

public function getUsername(): string
{
return $this->username;
Expand Down
5 changes: 0 additions & 5 deletions app/Domain/Database/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@

/**
* @extends AbstractRepository<User>
* @method User|null find($id, ?int $lockMode = null, ?int $lockVersion = null)
* @method User|null findOneBy(array $criteria, array $orderBy = null)
* @method User|null findOneById(int $id)
* @method User[] findAll()
* @method User[] findBy(array $criteria, array $orderBy = null, ?int $limit = null, ?int $offset = null)
*/
final class UserRepository extends AbstractRepository
{
Expand Down
27 changes: 0 additions & 27 deletions app/Model/Database/Entity/AbstractEntity.php

This file was deleted.

10 changes: 0 additions & 10 deletions app/Model/Database/EntityManagerDecorator.php

This file was deleted.

0 comments on commit 4964e84

Please sign in to comment.