master
xantxo coquillard 3 years ago
parent fbc49281d1
commit f7e226eb44

@ -20,7 +20,7 @@ services:
- '../src/Entity/'
- '../src/Kernel.php'
App\Controller\:
resource: '../src/App/Controller'
resource: '../src/Controller'
tags: ['controller.service_arguments']
# add more service definitions when explicit configuration is needed

@ -0,0 +1,29 @@
<?php
namespace App\Component\Customer\Infrastructure;
use App\Component\Customer\Domain\Customer;
use App\Component\Customer\Domain\CustomerDataMapper;
use App\Component\Customer\Domain\CustomerRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
class CustomerDatabaseAdapter extends ServiceEntityRepository implements CustomerDataMapper, CustomerRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Customer::class);
}
public function findById(int $id): Customer
{
// TODO: Implement findById() method.
}
public function findAll(): array
{
// TODO: Implement findAll() method.
}
}

@ -0,0 +1,18 @@
<?php
namespace App\Component\File\Domain;
#[ORM\Entity, ORM\Table(name:"files")]
class File
{
#[ORM\Id, ORM\GeneratedValue(strategy: 'AUTO')]
#[ORM\Column(type:Types::INTEGER)]
private int $id;
#[ORM\Column]
public \DateTime $created;
#[ORM\Column]
public \DateTime $updated;
}

@ -0,0 +1,8 @@
<?php
namespace App\Component\File\Domain;
interface FileDataMapper
{
}

@ -0,0 +1,9 @@
<?php
namespace App\Component\File\Domain;
interface FileRepository
{
public function findById(int $id): File;
public function findAll(): array;
}

@ -0,0 +1,29 @@
<?php
namespace App\Component\File\Infrastructure;
use App\Component\File\Domain\File;
use App\Component\File\Domain\FileDataMapper;
use App\Component\File\Domain\FileRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
class FileDatabaseAdapter extends ServiceEntityRepository implements FileDataMapper, FileRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, File::class);
}
public function findById(int $id): File
{
// TODO: Implement findById() method.
}
public function findAll(): array
{
// TODO: Implement findAll() method.
}
}

@ -0,0 +1,91 @@
<?php
namespace App\Component\Material\Domain;
use Doctrine\DBAL\Types\Types;
#[ORM\Entity, ORM\Table(name:"materials")]
class Material
{
#[ORM\Id, ORM\GeneratedValue(strategy: 'AUTO')]
#[ORM\Column(type:Types::INTEGER)]
private int $id;
#[ORM\Column(type:Types::STRING, length:255)]
private string $label;
#[ORM\Column]
public \DateTime $created;
#[ORM\Column]
public \DateTime $updated;
public function __construct()
{
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id): void
{
$this->id = $id;
}
/**
* @return string
*/
public function getLabel(): string
{
return $this->label;
}
/**
* @param string $label
*/
public function setLabel(string $label): void
{
$this->label = $label;
}
/**
* @return \DateTime
*/
public function getCreated(): \DateTime
{
return $this->created;
}
/**
* @param \DateTime $created
*/
public function setCreated(\DateTime $created): void
{
$this->created = $created;
}
/**
* @return \DateTime
*/
public function getUpdated(): \DateTime
{
return $this->updated;
}
/**
* @param \DateTime $updated
*/
public function setUpdated(\DateTime $updated): void
{
$this->updated = $updated;
}
}

@ -0,0 +1,8 @@
<?php
namespace App\Component\Material\Domain;
interface MaterialDataMapper
{
}

@ -0,0 +1,9 @@
<?php
namespace App\Component\Material\Domain;
interface MaterialRepository
{
public function findById(int $id): Material;
public function findAll(): array;
}

@ -0,0 +1,29 @@
<?php
namespace App\Component\Material\Infrastructure;
use App\Component\Material\Domain\Material;
use App\Component\Material\Domain\MaterialDataMapper;
use App\Component\Material\Domain\MaterialRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
class MaterialDatabaseAdapter extends ServiceEntityRepository implements MaterialDataMapper, MaterialRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Material::class);
}
public function findById(int $id): Material
{
// TODO: Implement findById() method.
}
public function findAll(): array
{
// TODO: Implement findAll() method.
}
}

@ -0,0 +1,255 @@
<?php
namespace App\Component\Order\Domain;
use App\Component\Customer\Domain\Customer;
use App\Component\File\Domain\File;
use App\Component\Printer\Domain\Printer;
use App\Component\Spool\Domain\Spool;
#[ORM\Entity, ORM\Table(name:"orders")]
class Order
{
#[ORM\Id, ORM\GeneratedValue(strategy: 'AUTO')]
#[ORM\Column(type:Types::INTEGER)]
private int $id;
private Printer $printer;
private Customer $customer;
private Spool $spool;
private float $printWeights;
private int $printMinutes;
private int $printHours;
private int $userHourlyCost;
private float $sellPrice;
private File $file;
private int $status;
#[ORM\Column]
public \DateTime $created;
#[ORM\Column]
public \DateTime $updated;
public function __construct()
{
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id): void
{
$this->id = $id;
}
/**
* @return Printer
*/
public function getPrinter(): Printer
{
return $this->printer;
}
/**
* @param Printer $printer
*/
public function setPrinter(Printer $printer): void
{
$this->printer = $printer;
}
/**
* @return Customer
*/
public function getCustomer(): Customer
{
return $this->customer;
}
/**
* @param Customer $customer
*/
public function setCustomer(Customer $customer): void
{
$this->customer = $customer;
}
/**
* @return Spool
*/
public function getSpool(): Spool
{
return $this->spool;
}
/**
* @param Spool $spool
*/
public function setSpool(Spool $spool): void
{
$this->spool = $spool;
}
/**
* @return float
*/
public function getPrintWeights(): float
{
return $this->printWeights;
}
/**
* @param float $printWeights
*/
public function setPrintWeights(float $printWeights): void
{
$this->printWeights = $printWeights;
}
/**
* @return int
*/
public function getPrintMinutes(): int
{
return $this->printMinutes;
}
/**
* @param int $printMinutes
*/
public function setPrintMinutes(int $printMinutes): void
{
$this->printMinutes = $printMinutes;
}
/**
* @return int
*/
public function getPrintHours(): int
{
return $this->printHours;
}
/**
* @param int $printHours
*/
public function setPrintHours(int $printHours): void
{
$this->printHours = $printHours;
}
/**
* @return int
*/
public function getUserHourlyCost(): int
{
return $this->userHourlyCost;
}
/**
* @param int $userHourlyCost
*/
public function setUserHourlyCost(int $userHourlyCost): void
{
$this->userHourlyCost = $userHourlyCost;
}
/**
* @return float
*/
public function getSellPrice(): float
{
return $this->sellPrice;
}
/**
* @param float $sellPrice
*/
public function setSellPrice(float $sellPrice): void
{
$this->sellPrice = $sellPrice;
}
/**
* @return File
*/
public function getFile(): File
{
return $this->file;
}
/**
* @param File $file
*/
public function setFile(File $file): void
{
$this->file = $file;
}
/**
* @return int
*/
public function getStatus(): int
{
return $this->status;
}
/**
* @param int $status
*/
public function setStatus(int $status): void
{
$this->status = $status;
}
/**
* @return \DateTime
*/
public function getCreated(): \DateTime
{
return $this->created;
}
/**
* @param \DateTime $created
*/
public function setCreated(\DateTime $created): void
{
$this->created = $created;
}
/**
* @return \DateTime
*/
public function getUpdated(): \DateTime
{
return $this->updated;
}
/**
* @param \DateTime $updated
*/
public function setUpdated(\DateTime $updated): void
{
$this->updated = $updated;
}
}

@ -0,0 +1,8 @@
<?php
namespace App\Component\Order\Domain;
interface OrderDataMapper
{
}

@ -0,0 +1,9 @@
<?php
namespace App\Component\Order\Domain;
interface OrderRepository
{
public function findById(int $id): Order;
public function findAll(): array;
}

@ -0,0 +1,29 @@
<?php
namespace App\Component\Order\Infrastructure;
use App\Component\Order\Domain\Order;
use App\Component\Order\Domain\OrderDataMapper;
use App\Component\Order\Domain\OrderRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
class OrderDatabaseAdapter extends ServiceEntityRepository implements OrderDataMapper, OrderRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Order::class);
}
public function findById(int $id): Order
{
// TODO: Implement findById() method.
}
public function findAll(): array
{
// TODO: Implement findAll() method.
}
}

@ -0,0 +1,8 @@
<?php
namespace App\Component\Printer\Domain;
class Printer
{
}

@ -0,0 +1,8 @@
<?php
namespace App\Component\Printer\Domain;
interface PrinterDataMapper
{
}

@ -0,0 +1,9 @@
<?php
namespace App\Component\Printer\Domain;
interface PrinterRepository
{
public function findById(int $id): Printer;
public function findAll(): array;
}

@ -0,0 +1,29 @@
<?php
namespace App\Component\Printer\Infrastructure;
use App\Component\Printer\Domain\Printer;
use App\Component\Printer\Domain\PrinterDataMapper;
use App\Component\Printer\Domain\PrinterRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
class PrinterDatabaseAdapter extends ServiceEntityRepository implements PrinterDataMapper, PrinterRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Printer::class);
}
public function findById(int $id): Printer
{
// TODO: Implement findById() method.
}
public function findAll(): array
{
// TODO: Implement findAll() method.
}
}

@ -2,8 +2,12 @@
namespace App\Component\Role\Domain;
use App\Component\User\Domain\User;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use JetBrains\PhpStorm\Pure;
#[ORM\Entity, ORM\Table(name:"roles")]
@ -17,14 +21,19 @@ class Role
#[ORM\Column(type:Types::STRING, length:255)]
private string $name;
#[ORM\OneToMany(mappedBy:"role", targetEntity: User::class)]
private Collection $users;
#[ORM\Column]
public \DateTime $created;
#[ORM\Column]
public \DateTime $updated;
#[Pure]
public function __construct()
{
$this->users = new ArrayCollection();
}
/**
@ -59,4 +68,52 @@ class Role
$this->name = $name;
}
/**
* @return Collection
*/
public function getUsers(): Collection
{
return $this->users;
}
/**
* @param Collection $user
*/
public function setUsers(Collection $users): void
{
$this->users = $users;
}
/**
* @return \DateTime
*/
public function getCreated(): \DateTime
{
return $this->created;
}
/**
* @param \DateTime $created
*/
public function setCreated(\DateTime $created): void
{
$this->created = $created;
}
/**
* @return \DateTime
*/
public function getUpdated(): \DateTime
{
return $this->updated;
}
/**
* @param \DateTime $updated
*/
public function setUpdated(\DateTime $updated): void
{
$this->updated = $updated;
}
}

@ -19,16 +19,16 @@ class RoleDatabaseAdapter extends ServiceEntityRepository implements RoleDataMap
public function findById(int $id): Role
{
$user = $this->find($id);
$role = $this->find($id);
if (!$user)
if (!$role)
{
throw new Exception(
'L\'utilisateur n\'existe pas'
'Le role n\'existe pas'
);
}
return $user;
return $role;
}
public function findAll(): array

@ -0,0 +1,8 @@
<?php
namespace App\Component\Spool\Domain;
class Spool
{
}

@ -0,0 +1,8 @@
<?php
namespace App\Component\Spool\Domain;
interface SpoolDataMapper
{
}

@ -0,0 +1,9 @@
<?php
namespace App\Component\Spool\Domain;
interface SpoolRepository
{
public function findById(int $id): Spool;
public function findAll(): array;
}

@ -0,0 +1,29 @@
<?php
namespace App\Component\Spool\Infrastructure;
use App\Component\Spool\Domain\Spool;
use App\Component\Spool\Domain\SpoolDataMapper;
use App\Component\Spool\Domain\SpoolRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
class SpoolDatabaseAdapter extends ServiceEntityRepository implements SpoolDataMapper, SpoolRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Spool::class);
}
public function findById(int $id): Spool
{
// TODO: Implement findById() method.
}
public function findAll() : array
{
}
}

@ -21,10 +21,7 @@ class User
#[ORM\Column(type:Types::STRING, length:255)]
private string $firstname;
#[ORM\OneToOne(mappedBy:"role", targetEntity: Role::class)]
#[ORM\JoinTable(name:"roles")]
#[ORM\JoinColumn(name: "role_id", referencedColumnName: "id")]
#[ORM\InverseJoinColumn(name: "id", referencedColumnName: "role_id")]
#[ORM\ManyToOne(targetEntity: Role::class, inversedBy:"users")]
protected Role $role;
#[ORM\Column(type:Types::DECIMAL,length:10, precision:2)]

@ -0,0 +1,8 @@
<?php
namespace App\Component\UserMaterial\Domain;
class UserMaterial
{
}

@ -0,0 +1,8 @@
<?php
namespace App\Component\UserMaterial\Domain;
interface UserMaterialDataMapper
{
}

@ -0,0 +1,9 @@
<?php
namespace App\Component\UserMaterial\Domain;
interface UserMaterialRepository
{
public function findById(int $id): UserMaterial;
public function findAll(): array;
}

@ -0,0 +1,28 @@
<?php
namespace App\Component\UserMaterial\Infrastructure;
use App\Component\UserMaterial\Domain\UserMaterial;
use App\Component\UserMaterial\Domain\UserMaterialDataMapper;
use App\Component\UserMaterial\Domain\UserMaterialRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
class UserMaterialDatabaseAdapter extends ServiceEntityRepository implements UserMaterialDataMapper, UserMaterialRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, UserMaterial::class);
}
public function findById(int $id): UserMaterial
{
// TODO: Implement findById() method.
}
public function findAll(): array
{
// TODO: Implement findAll() method.
}
}

@ -2,6 +2,7 @@
namespace App\Controller;
use App\Component\Order\Infrastructure\OrderDatabaseAdapter;
use App\Component\Role\Infrastructure\RoleDatabaseAdapter;
use App\Component\User\Infrastructure\UserDatabaseAdapter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -20,6 +21,7 @@ class TestController extends AbstractController
public function index(UserDatabaseAdapter $DoctrineUser): Response
{
$user = $DoctrineUser->findById(1);
dd($user->getRole()->getUsers());
return new Response(
$user->getId(). " " .$user->getName(),
Response::HTTP_OK,

Loading…
Cancel
Save