Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
ab95de45a8 | |||
f7e226eb44 | |||
fbc49281d1 | |||
57529e871e | |||
30e8edc728 | |||
706166fa26 | |||
c8c3b42b0e | |||
3c646640dc | |||
0934124428 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,3 +9,4 @@
|
||||
/vendor/
|
||||
###< symfony/framework-bundle ###
|
||||
.env
|
||||
.idea
|
||||
|
@ -7,15 +7,19 @@
|
||||
"php": ">=8.0.2",
|
||||
"ext-ctype": "*",
|
||||
"ext-iconv": "*",
|
||||
"doctrine/annotations": "^1.13",
|
||||
"doctrine/doctrine-bundle": "^2.6",
|
||||
"doctrine/doctrine-migrations-bundle": "^3.2",
|
||||
"doctrine/orm": "^2.11",
|
||||
"symfony/console": "6.0.*",
|
||||
"symfony/dotenv": "6.0.*",
|
||||
"symfony/expression-language": "6.0.*",
|
||||
"symfony/flex": "^2",
|
||||
"symfony/framework-bundle": "6.0.*",
|
||||
"symfony/proxy-manager-bridge": "6.0.*",
|
||||
"symfony/runtime": "6.0.*",
|
||||
"symfony/yaml": "6.0.*"
|
||||
},
|
||||
"require-dev": {
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"composer/package-versions-deprecated": true,
|
||||
@ -66,5 +70,8 @@
|
||||
"allow-contrib": false,
|
||||
"require": "6.0.*"
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/maker-bundle": "^1.38"
|
||||
}
|
||||
}
|
||||
|
1961
composer.lock
generated
1961
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -2,4 +2,7 @@
|
||||
|
||||
return [
|
||||
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
|
||||
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
|
||||
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
|
||||
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
|
||||
];
|
||||
|
42
config/packages/doctrine.yaml
Normal file
42
config/packages/doctrine.yaml
Normal file
@ -0,0 +1,42 @@
|
||||
doctrine:
|
||||
dbal:
|
||||
url: '%env(resolve:DATABASE_URL)%'
|
||||
|
||||
# IMPORTANT: You MUST configure your server version,
|
||||
# either here or in the DATABASE_URL env var (see .env file)
|
||||
#server_version: '13'
|
||||
orm:
|
||||
auto_generate_proxy_classes: true
|
||||
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
|
||||
auto_mapping: true
|
||||
mappings:
|
||||
App:
|
||||
is_bundle: false
|
||||
dir: '%kernel.project_dir%/src/Component'
|
||||
prefix: 'App\Component'
|
||||
alias: App
|
||||
|
||||
when@test:
|
||||
doctrine:
|
||||
dbal:
|
||||
# "TEST_TOKEN" is typically set by ParaTest
|
||||
dbname_suffix: '_test%env(default::TEST_TOKEN)%'
|
||||
|
||||
when@prod:
|
||||
doctrine:
|
||||
orm:
|
||||
auto_generate_proxy_classes: false
|
||||
query_cache_driver:
|
||||
type: pool
|
||||
pool: doctrine.system_cache_pool
|
||||
result_cache_driver:
|
||||
type: pool
|
||||
pool: doctrine.result_cache_pool
|
||||
|
||||
framework:
|
||||
cache:
|
||||
pools:
|
||||
doctrine.result_cache_pool:
|
||||
adapter: cache.app
|
||||
doctrine.system_cache_pool:
|
||||
adapter: cache.system
|
6
config/packages/doctrine_migrations.yaml
Normal file
6
config/packages/doctrine_migrations.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
doctrine_migrations:
|
||||
migrations_paths:
|
||||
# namespace is arbitrary but should be different from App\Migrations
|
||||
# as migrations classes should NOT be autoloaded
|
||||
'DoctrineMigrations': '%kernel.project_dir%/migrations'
|
||||
enable_profiler: '%kernel.debug%'
|
@ -19,6 +19,9 @@ services:
|
||||
- '../src/DependencyInjection/'
|
||||
- '../src/Entity/'
|
||||
- '../src/Kernel.php'
|
||||
App\Controller\:
|
||||
resource: '../src/Controller'
|
||||
tags: ['controller.service_arguments']
|
||||
|
||||
# add more service definitions when explicit configuration is needed
|
||||
# please note that last definitions always *replace* previous ones
|
||||
|
0
migrations/.gitignore
vendored
Normal file
0
migrations/.gitignore
vendored
Normal file
33
migrations/Version20220407211354.php
Normal file
33
migrations/Version20220407211354.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?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 Version20220407211354 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 roles (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE users (id INT AUTO_INCREMENT NOT NULL, lastname VARCHAR(255) NOT NULL, firstname VARCHAR(255) NOT NULL, kwh_price NUMERIC(2, 0) NOT NULL, hourly_cost NUMERIC(2, 0) NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('DROP TABLE roles');
|
||||
$this->addSql('DROP TABLE users');
|
||||
}
|
||||
}
|
56
src/Component/Customer/Domain/Customer.php
Normal file
56
src/Component/Customer/Domain/Customer.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Customer\Domain;
|
||||
|
||||
use App\Component\File\Domain\File;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
#[ORM\Entity, ORM\Table(name:"customers")]
|
||||
class Customer
|
||||
{
|
||||
#[ORM\Id, ORM\GeneratedValue(strategy: 'AUTO')]
|
||||
#[ORM\Column(type:Types::INTEGER)]
|
||||
private int $id;
|
||||
|
||||
#[ORM\OneToOne(mappedBy:"user", targetEntity: User::class)]
|
||||
#[ORM\JoinTable(name:"users")]
|
||||
#[ORM\JoinColumn(name: "user_id", referencedColumnName: "id")]
|
||||
#[ORM\InverseJoinColumn(name: "id", referencedColumnName: "user_id")]
|
||||
protected User $user;
|
||||
|
||||
#[ORM\Column(type:Types::STRING, length:255)]
|
||||
private string $lastname;
|
||||
|
||||
#[ORM\Column(type:Types::STRING, length:255)]
|
||||
private string $firstname;
|
||||
|
||||
#[ORM\Column(type:Types::STRING, length:10)]
|
||||
private string $phoneNumber;
|
||||
|
||||
#[ORM\Column(type:Types::STRING, length:3)]
|
||||
private string $callSign;
|
||||
|
||||
#[ORM\Column(type:Types::String, length:255)]
|
||||
private string $email;
|
||||
|
||||
#[ORM\Column(type:Types::String, length:255)]
|
||||
private string $adresse;
|
||||
|
||||
#[ORM\Column(type:Types::String, length:150)]
|
||||
private string $country;
|
||||
|
||||
#[ORM\Column(type:Types::String, length:25)]
|
||||
private string $postcode;
|
||||
|
||||
#[ORM\Column(type:Types::String, length:100)]
|
||||
private string $city;
|
||||
|
||||
#[ORM\OneToMany(mappedBy:"customer", targetEntity: File::class)]
|
||||
private Collection $files;
|
||||
|
||||
#[ORM\Column]
|
||||
public \DateTime $created;
|
||||
|
||||
#[ORM\Column]
|
||||
public \DateTime $updated;
|
||||
}
|
9
src/Component/Customer/Domain/CustomerDataMapper.php
Normal file
9
src/Component/Customer/Domain/CustomerDataMapper.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Customer\Domain;
|
||||
|
||||
interface CustomerDataMapper
|
||||
{
|
||||
|
||||
|
||||
}
|
9
src/Component/Customer/Domain/CustomerRepository.php
Normal file
9
src/Component/Customer/Domain/CustomerRepository.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Customer\Domain;
|
||||
|
||||
interface CustomerRepository
|
||||
{
|
||||
public function findById(int $id): Customer;
|
||||
public function findAll(): array;
|
||||
}
|
@ -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.
|
||||
}
|
||||
|
||||
}
|
23
src/Component/File/Domain/File.php
Normal file
23
src/Component/File/Domain/File.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\File\Domain;
|
||||
|
||||
use App\Component\Customer\Domain\Customer;
|
||||
|
||||
#[ORM\Entity, ORM\Table(name:"files")]
|
||||
class File
|
||||
{
|
||||
#[ORM\Id, ORM\GeneratedValue(strategy: 'AUTO')]
|
||||
#[ORM\Column(type:Types::INTEGER)]
|
||||
private int $id;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Customer::class, inversedBy:"files")]
|
||||
private Customer $customer;
|
||||
|
||||
#[ORM\Column]
|
||||
public \DateTime $created;
|
||||
|
||||
#[ORM\Column]
|
||||
public \DateTime $updated;
|
||||
|
||||
}
|
8
src/Component/File/Domain/FileDataMapper.php
Normal file
8
src/Component/File/Domain/FileDataMapper.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\File\Domain;
|
||||
|
||||
interface FileDataMapper
|
||||
{
|
||||
|
||||
}
|
9
src/Component/File/Domain/FileRepository.php
Normal file
9
src/Component/File/Domain/FileRepository.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\File\Domain;
|
||||
|
||||
interface FileRepository
|
||||
{
|
||||
public function findById(int $id): File;
|
||||
public function findAll(): array;
|
||||
}
|
29
src/Component/File/Infrastructure/FileDatabaseAdapter.php
Normal file
29
src/Component/File/Infrastructure/FileDatabaseAdapter.php
Normal file
@ -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.
|
||||
}
|
||||
|
||||
}
|
91
src/Component/Material/Domain/Material.php
Normal file
91
src/Component/Material/Domain/Material.php
Normal file
@ -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;
|
||||
}
|
||||
|
||||
}
|
8
src/Component/Material/Domain/MaterialDataMapper.php
Normal file
8
src/Component/Material/Domain/MaterialDataMapper.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Material\Domain;
|
||||
|
||||
interface MaterialDataMapper
|
||||
{
|
||||
|
||||
}
|
9
src/Component/Material/Domain/MaterialRepository.php
Normal file
9
src/Component/Material/Domain/MaterialRepository.php
Normal file
@ -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.
|
||||
}
|
||||
|
||||
}
|
255
src/Component/Order/Domain/Order.php
Normal file
255
src/Component/Order/Domain/Order.php
Normal file
@ -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;
|
||||
}
|
||||
|
||||
}
|
8
src/Component/Order/Domain/OrderDataMapper.php
Normal file
8
src/Component/Order/Domain/OrderDataMapper.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Order\Domain;
|
||||
|
||||
interface OrderDataMapper
|
||||
{
|
||||
|
||||
}
|
9
src/Component/Order/Domain/OrderRepository.php
Normal file
9
src/Component/Order/Domain/OrderRepository.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Order\Domain;
|
||||
|
||||
interface OrderRepository
|
||||
{
|
||||
public function findById(int $id): Order;
|
||||
public function findAll(): array;
|
||||
}
|
29
src/Component/Order/Infrastructure/OrderDatabaseAdapter.php
Normal file
29
src/Component/Order/Infrastructure/OrderDatabaseAdapter.php
Normal file
@ -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.
|
||||
}
|
||||
|
||||
}
|
8
src/Component/Printer/Domain/Printer.php
Normal file
8
src/Component/Printer/Domain/Printer.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Printer\Domain;
|
||||
|
||||
class Printer
|
||||
{
|
||||
|
||||
}
|
8
src/Component/Printer/Domain/PrinterDataMapper.php
Normal file
8
src/Component/Printer/Domain/PrinterDataMapper.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Printer\Domain;
|
||||
|
||||
interface PrinterDataMapper
|
||||
{
|
||||
|
||||
}
|
9
src/Component/Printer/Domain/PrinterRepository.php
Normal file
9
src/Component/Printer/Domain/PrinterRepository.php
Normal file
@ -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.
|
||||
}
|
||||
|
||||
}
|
119
src/Component/Role/Domain/Role.php
Normal file
119
src/Component/Role/Domain/Role.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
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")]
|
||||
class Role
|
||||
{
|
||||
|
||||
#[ORM\Id, ORM\GeneratedValue(strategy: 'AUTO')]
|
||||
#[ORM\Column(type:Types::INTEGER)]
|
||||
private int $id;
|
||||
|
||||
#[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();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName(string $name): void
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
}
|
8
src/Component/Role/Domain/RoleDataMapper.php
Normal file
8
src/Component/Role/Domain/RoleDataMapper.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Role\Domain;
|
||||
|
||||
interface RoleDataMapper
|
||||
{
|
||||
|
||||
}
|
9
src/Component/Role/Domain/RoleRepository.php
Normal file
9
src/Component/Role/Domain/RoleRepository.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Role\Domain;
|
||||
|
||||
interface RoleRepository
|
||||
{
|
||||
public function findById(int $id): Role;
|
||||
public function findAll(): array;
|
||||
}
|
38
src/Component/Role/Infrastructure/RoleDatabaseAdapter.php
Normal file
38
src/Component/Role/Infrastructure/RoleDatabaseAdapter.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Role\Infrastructure;
|
||||
|
||||
use App\Component\Role\Domain\Role;
|
||||
use App\Component\Role\Domain\RoleDataMapper;
|
||||
use App\Component\Role\Domain\RoleRepository;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Exception;
|
||||
|
||||
class RoleDatabaseAdapter extends ServiceEntityRepository implements RoleDataMapper, RoleRepository
|
||||
{
|
||||
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Role::class);
|
||||
}
|
||||
|
||||
public function findById(int $id): Role
|
||||
{
|
||||
$role = $this->find($id);
|
||||
|
||||
if (!$role)
|
||||
{
|
||||
throw new Exception(
|
||||
'Le role n\'existe pas'
|
||||
);
|
||||
}
|
||||
|
||||
return $role;
|
||||
}
|
||||
|
||||
public function findAll(): array
|
||||
{
|
||||
// TODO: Implement findAll() method.
|
||||
}
|
||||
}
|
8
src/Component/Spool/Domain/Spool.php
Normal file
8
src/Component/Spool/Domain/Spool.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Spool\Domain;
|
||||
|
||||
class Spool
|
||||
{
|
||||
|
||||
}
|
8
src/Component/Spool/Domain/SpoolDataMapper.php
Normal file
8
src/Component/Spool/Domain/SpoolDataMapper.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Spool\Domain;
|
||||
|
||||
interface SpoolDataMapper
|
||||
{
|
||||
|
||||
}
|
9
src/Component/Spool/Domain/SpoolRepository.php
Normal file
9
src/Component/Spool/Domain/SpoolRepository.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Spool\Domain;
|
||||
|
||||
interface SpoolRepository
|
||||
{
|
||||
public function findById(int $id): Spool;
|
||||
public function findAll(): array;
|
||||
}
|
29
src/Component/Spool/Infrastructure/SpoolDatabaseAdapter.php
Normal file
29
src/Component/Spool/Infrastructure/SpoolDatabaseAdapter.php
Normal file
@ -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
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
172
src/Component/User/Domain/User.php
Normal file
172
src/Component/User/Domain/User.php
Normal file
@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\User\Domain;
|
||||
|
||||
use App\Component\Role\Domain\Role;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
|
||||
#[ORM\Entity, ORM\Table(name:"users")]
|
||||
class User
|
||||
{
|
||||
|
||||
#[ORM\Id, ORM\GeneratedValue(strategy: 'AUTO')]
|
||||
#[ORM\Column(type:Types::INTEGER)]
|
||||
private int $id;
|
||||
|
||||
#[ORM\Column(type:Types::STRING, length:255)]
|
||||
private string $lastname;
|
||||
|
||||
#[ORM\Column(type:Types::STRING, length:255)]
|
||||
private string $firstname;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Role::class, inversedBy:"users")]
|
||||
protected Role $role;
|
||||
|
||||
#[ORM\Column(type:Types::DECIMAL,length:10, precision:2)]
|
||||
private float $kwhPrice;
|
||||
|
||||
#[ORM\Column(type:Types::DECIMAL,length:10, precision:2)]
|
||||
private float $hourlyCost;
|
||||
|
||||
#[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 getLastname(): string
|
||||
{
|
||||
return $this->lastname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $lastname
|
||||
*/
|
||||
public function setLastname(string $lastname): void
|
||||
{
|
||||
$this->lastname = $lastname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFirstname(): string
|
||||
{
|
||||
return $this->firstname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $firstname
|
||||
*/
|
||||
public function setFirstname(string $firstname): void
|
||||
{
|
||||
$this->firstname = $firstname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Role
|
||||
*/
|
||||
public function getRole(): Role
|
||||
{
|
||||
return $this->role;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Role $role
|
||||
*/
|
||||
public function setRole(Role $role): void
|
||||
{
|
||||
$this->role = $role;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getKwhPrice(): float
|
||||
{
|
||||
return $this->kwhPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $kwhPrice
|
||||
*/
|
||||
public function setKwhPrice(float $kwhPrice): void
|
||||
{
|
||||
$this->kwhPrice = $kwhPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getHourlyCost(): float
|
||||
{
|
||||
return $this->hourlyCost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $hourlyCost
|
||||
*/
|
||||
public function setHourlyCost(float $hourlyCost): void
|
||||
{
|
||||
$this->hourlyCost = $hourlyCost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
||||
}
|
8
src/Component/User/Domain/UserDataMapper.php
Normal file
8
src/Component/User/Domain/UserDataMapper.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\User\Domain;
|
||||
|
||||
interface UserDataMapper
|
||||
{
|
||||
|
||||
}
|
9
src/Component/User/Domain/UserRepository.php
Normal file
9
src/Component/User/Domain/UserRepository.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\User\Domain;
|
||||
|
||||
interface UserRepository
|
||||
{
|
||||
public function findById(int $id): User;
|
||||
public function findAll(): array;
|
||||
}
|
38
src/Component/User/Infrastructure/UserDatabaseAdapter.php
Normal file
38
src/Component/User/Infrastructure/UserDatabaseAdapter.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\User\Infrastructure;
|
||||
|
||||
use App\Component\User\Domain\User;
|
||||
use App\Component\User\Domain\UserDataMapper;
|
||||
use App\Component\User\Domain\UserRepository;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Exception;
|
||||
|
||||
class UserDatabaseAdapter extends ServiceEntityRepository implements UserDataMapper, UserRepository
|
||||
{
|
||||
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, User::class);
|
||||
}
|
||||
|
||||
public function findById(int $id): User
|
||||
{
|
||||
$user = $this->find($id);
|
||||
|
||||
if (!$user)
|
||||
{
|
||||
throw new Exception(
|
||||
'L\'utilisateur n\'existe pas'
|
||||
);
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function findAll(): array
|
||||
{
|
||||
// TODO: Implement findAll() method.
|
||||
}
|
||||
}
|
8
src/Component/UserMaterial/Domain/UserMaterial.php
Normal file
8
src/Component/UserMaterial/Domain/UserMaterial.php
Normal file
@ -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.
|
||||
}
|
||||
}
|
31
src/Controller/TestController.php
Normal file
31
src/Controller/TestController.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use function dd;
|
||||
|
||||
class TestController extends AbstractController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
#[Route('/testUser')]
|
||||
public function index(UserDatabaseAdapter $DoctrineUser): Response
|
||||
{
|
||||
$user = $DoctrineUser->findById(1);
|
||||
dd($user->getRole()->getUsers());
|
||||
return new Response(
|
||||
$user->getId(). " " .$user->getName(),
|
||||
Response::HTTP_OK,
|
||||
['content-type' => 'text/html']
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user