first changes for devenv
This commit is contained in:
parent
d70e2d6192
commit
7ac14134df
@ -3,7 +3,7 @@
|
||||
require_once __DIR__ . '/../config/autoload/defines.php';
|
||||
require APP_ROOT . '/vendor/autoload.php';
|
||||
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Template\Data\Business\Manager\EntityManager;
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
use Doctrine\Migrations\Configuration\Configuration;
|
||||
@ -40,7 +40,7 @@ $driver = new AnnotationDriver($reader, $paths);
|
||||
|
||||
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
|
||||
$config->setMetadataDriverImpl($driver);
|
||||
$entityManager = $container->get(TemplateEntityManager::class);
|
||||
$entityManager = $container->get(EntityManager::class);
|
||||
|
||||
try {
|
||||
$connection = DriverManager::getConnection($dbParams);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
require_once __DIR__ . '/../config/autoload/defines.php';
|
||||
require APP_ROOT . '/vendor/autoload.php';
|
||||
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Template\Data\Business\Manager\EntityManager;
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
use Doctrine\Migrations\Configuration\Configuration;
|
||||
@ -40,7 +40,7 @@ $driver = new AnnotationDriver($reader, $paths);
|
||||
|
||||
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
|
||||
$config->setMetadataDriverImpl($driver);
|
||||
$entityManager = $container->get(TemplateEntityManager::class);
|
||||
$entityManager = $container->get(EntityManager::class);
|
||||
|
||||
try {
|
||||
$connection = DriverManager::getConnection($dbParams);
|
||||
|
||||
@ -54,7 +54,6 @@ $aggregator = new ConfigAggregator([
|
||||
\Template\Infrastructure\Session\ConfigProvider::class,
|
||||
|
||||
// HandlingDomain
|
||||
\Template\Handling\Product\ConfigProvider::class,
|
||||
\Template\Handling\User\ConfigProvider::class,
|
||||
\Template\Handling\UserSession\ConfigProvider::class,
|
||||
\Template\Handling\Registration\ConfigProvider::class,
|
||||
@ -65,7 +64,6 @@ $aggregator = new ConfigAggregator([
|
||||
|
||||
/// External
|
||||
\Template\API\External\Health\ConfigProvider::class,
|
||||
\Template\API\External\Product\ConfigProvider::class,
|
||||
\Template\API\External\User\ConfigProvider::class,
|
||||
\Template\API\External\Authentication\ConfigProvider::class,
|
||||
|
||||
|
||||
@ -18,7 +18,6 @@ final class Version20230922085011 extends AbstractMigration
|
||||
{
|
||||
$sql = "CREATE TABLE role (
|
||||
id binary(16) NOT NULL,
|
||||
product_id binary(16) DEFAULT NULL,
|
||||
identifier varchar(255) UNIQUE NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);";
|
||||
@ -21,7 +21,6 @@ final class Version20230922092351 extends AbstractMigration
|
||||
{
|
||||
$sql = "CREATE TABLE permission (
|
||||
id binary(16) NOT NULL,
|
||||
product_id binary(16) DEFAULT NULL,
|
||||
identifier varchar(255) UNIQUE NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);";
|
||||
@ -23,7 +23,6 @@ final class Version20230924113403 extends AbstractMigration
|
||||
id binary(16) NOT NULL,
|
||||
mail varchar(255) NOT NULL,
|
||||
username varchar(255) NOT NULL,
|
||||
password varchar(255) NOT NULL,
|
||||
created_at datetime NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);";
|
||||
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\Migrations\Template;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20230922101352 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return "Create Table 'product'";
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$sql = "CREATE TABLE product (
|
||||
id binary(16) NOT NULL,
|
||||
identifier varchar(255) UNIQUE NOT NULL,
|
||||
name varchar(255) DEFAULT NULL,
|
||||
updated_at datetime NOT NULL,
|
||||
created_at datetime NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);";
|
||||
|
||||
$this->addSql($sql);
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql("DROP TABLE product;");
|
||||
}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\Migrations\Template;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20231021103120 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'drop password from registration';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$sql = "ALTER TABLE registration DROP COLUMN password;";
|
||||
|
||||
$this->addSql($sql);
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$sql = "ALTER TABLE registration ADD COLUMN password varchar(255) NOT NULL after username";
|
||||
|
||||
$this->addSql($sql);
|
||||
}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\Migrations\Template;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20231021112654 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add url to product';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$sql = "ALTER TABLE product ADD COLUMN url varchar(255) NULL after name";
|
||||
|
||||
$this->addSql($sql);
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$sql = "ALTER TABLE product DROP COLUMN url;";
|
||||
|
||||
$this->addSql($sql);
|
||||
}
|
||||
}
|
||||
@ -6,7 +6,7 @@ use Template\Data\Business\Entity\Role;
|
||||
use Template\Data\Business\Entity\User;
|
||||
use Template\Data\Business\Repository\RoleRepository;
|
||||
use Template\Data\Business\Repository\UserRepository;
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Template\Data\Business\Manager\EntityManager;
|
||||
use Template\Infrastructure\Encryption\Client\EncryptionClient;
|
||||
use Template\Infrastructure\Logging\Logger\Logger;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
@ -23,7 +23,7 @@ class InitializeDataCommand extends Command
|
||||
|
||||
public function __construct(
|
||||
private readonly EncryptionClient $encryptionClient,
|
||||
private readonly TemplateEntityManager $entityManager,
|
||||
private readonly EntityManager $entityManager,
|
||||
private readonly Logger $logger,
|
||||
) {
|
||||
parent::__construct($this->getName());
|
||||
|
||||
@ -6,7 +6,7 @@ use Template\Data\Business\Entity\Permission;
|
||||
use Template\Data\Business\Entity\Role;
|
||||
use Template\Data\Business\Repository\PermissionRepository;
|
||||
use Template\Data\Business\Repository\RoleRepository;
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Template\Data\Business\Manager\EntityManager;
|
||||
use Template\Infrastructure\Logging\Logger\Logger;
|
||||
use Reinfi\DependencyInjection\Service\ConfigService;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
@ -24,7 +24,7 @@ class RbacUpdateCommand extends Command
|
||||
|
||||
public function __construct(
|
||||
private readonly ConfigService $configService,
|
||||
private readonly TemplateEntityManager $entityManager,
|
||||
private readonly EntityManager $entityManager,
|
||||
private readonly Logger $logger,
|
||||
) {
|
||||
parent::__construct($this->getName());
|
||||
|
||||
@ -46,7 +46,7 @@ return [
|
||||
|
||||
'migrations_configuration' => [
|
||||
'orm_template' => [
|
||||
'directory' => 'data/migrations/template',
|
||||
'directory' => 'data/migrations/business',
|
||||
'name' => 'Doctrine Database Migrations for Template',
|
||||
'namespace' => 'Template\Migrations\Template',
|
||||
'table' => 'migrations',
|
||||
|
||||
@ -1,21 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Template\Data\Business\Entity\User;
|
||||
use Template\Data\Business\Factory\TemplateEntityManagerFactory;
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Template\Data\Business\Factory\EntityManagerFactory;
|
||||
use Template\Data\Business\Manager\EntityManager;
|
||||
use Template\Data\Business\Repository\UserRepository;
|
||||
use Template\Infrastructure\Database\AutowireRepositoryFactory;
|
||||
use Roave\PsrContainerDoctrine\ConfigurationFactory;
|
||||
use Roave\PsrContainerDoctrine\ConnectionFactory;
|
||||
use Roave\PsrContainerDoctrine\EntityManagerFactory;
|
||||
use Roave\PsrContainerDoctrine\EntityManagerFactory as BaseEntityManagerFactory;
|
||||
|
||||
return [
|
||||
'factories' => [
|
||||
'doctrine.entity_manager.orm_template' => [EntityManagerFactory::class, 'orm_template'],
|
||||
'doctrine.entity_manager.orm_template' => [BaseEntityManagerFactory::class, 'orm_template'],
|
||||
'doctrine.configuration.orm_template' => [ConfigurationFactory::class, 'orm_template'],
|
||||
'doctrine.connection.orm_template' => [ConnectionFactory::class, 'orm_template'],
|
||||
TemplateEntityManager::class => TemplateEntityManagerFactory::class,
|
||||
EntityManager::class => EntityManagerFactory::class,
|
||||
|
||||
UserRepository::class => [AutowireRepositoryFactory::class, TemplateEntityManager::class, User::class],
|
||||
UserRepository::class => [AutowireRepositoryFactory::class, EntityManager::class, User::class],
|
||||
],
|
||||
];
|
||||
|
||||
@ -19,15 +19,6 @@ class Permission {
|
||||
*/
|
||||
private UuidInterface $id;
|
||||
|
||||
/** @ORM\Column(name="product_id", type="uuid_binary_ordered_time", nullable=true) */
|
||||
private ?UuidInterface $productId;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="Template\Data\Business\Entity\Product")
|
||||
* @ORM\JoinColumn(name="product_id", referencedColumnName="id", nullable=true)
|
||||
*/
|
||||
private ?Product $product;
|
||||
|
||||
/** @ORM\Column(name="identifier", type="string") */
|
||||
private string $identifier;
|
||||
|
||||
@ -52,22 +43,6 @@ class Permission {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getProductId(): ?UuidInterface {
|
||||
return $this->productId;
|
||||
}
|
||||
|
||||
public function setProductId(?UuidInterface $productId): void {
|
||||
$this->productId = $productId;
|
||||
}
|
||||
|
||||
public function getProduct(): ?Product {
|
||||
return $this->product;
|
||||
}
|
||||
|
||||
public function setProduct(?Product $product): void {
|
||||
$this->product = $product;
|
||||
}
|
||||
|
||||
public function getIdentifier(): string {
|
||||
return $this->identifier;
|
||||
}
|
||||
|
||||
@ -20,15 +20,6 @@ class Role {
|
||||
*/
|
||||
private UuidInterface $id;
|
||||
|
||||
/** @ORM\Column(name="product_id", type="uuid_binary_ordered_time", nullable=true) */
|
||||
private ?UuidInterface $productId;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="Template\Data\Business\Entity\Product")
|
||||
* @ORM\JoinColumn(name="product_id", referencedColumnName="id", nullable=true)
|
||||
*/
|
||||
private ?Product $product;
|
||||
|
||||
/** @ORM\Column(name="identifier", type="string") */
|
||||
private string $identifier;
|
||||
|
||||
@ -53,22 +44,6 @@ class Role {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getProductId(): ?UuidInterface {
|
||||
return $this->productId;
|
||||
}
|
||||
|
||||
public function setProductId(?UuidInterface $productId): void {
|
||||
$this->productId = $productId;
|
||||
}
|
||||
|
||||
public function getProduct(): ?Product {
|
||||
return $this->product;
|
||||
}
|
||||
|
||||
public function setProduct(?Product $product): void {
|
||||
$this->product = $product;
|
||||
}
|
||||
|
||||
public function getIdentifier(): string {
|
||||
return $this->identifier;
|
||||
}
|
||||
|
||||
@ -4,15 +4,15 @@ declare(strict_types=1);
|
||||
|
||||
namespace Template\Data\Business\Factory;
|
||||
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Template\Data\Business\Manager\EntityManager;
|
||||
use Laminas\ServiceManager\Factory\FactoryInterface;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class TemplateEntityManagerFactory implements FactoryInterface
|
||||
class EntityManagerFactory implements FactoryInterface
|
||||
{
|
||||
public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): TemplateEntityManager
|
||||
public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): EntityManager
|
||||
{
|
||||
return new TemplateEntityManager(
|
||||
return new EntityManager(
|
||||
$container->get('doctrine.entity_manager.orm_template')
|
||||
);
|
||||
}
|
||||
@ -6,6 +6,6 @@ namespace Template\Data\Business\Manager;
|
||||
|
||||
use Doctrine\ORM\Decorator\EntityManagerDecorator;
|
||||
|
||||
class TemplateEntityManager extends EntityManagerDecorator
|
||||
class EntityManager extends EntityManagerDecorator
|
||||
{
|
||||
}
|
||||
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Template\Handling\Product\Builder\ProductBuilder;
|
||||
use Template\Handling\Product\Handler\Command\CreateProduct\CreateProductCommandBuilder;
|
||||
use Template\Handling\Product\Handler\Command\CreateProduct\CreateProductCommandHandler;
|
||||
use Template\Handling\Product\Handler\Command\DeleteProduct\DeleteProductCommandBuilder;
|
||||
use Template\Handling\Product\Handler\Command\DeleteProduct\DeleteProductCommandHandler;
|
||||
use Template\Handling\Product\Handler\Command\UpdateProduct\UpdateProductCommandBuilder;
|
||||
use Template\Handling\Product\Handler\Command\UpdateProduct\UpdateProductCommandHandler;
|
||||
use Template\Handling\Product\Handler\Query\ProductList\ProductListQueryBuilder;
|
||||
use Template\Handling\Product\Handler\Query\ProductList\ProductListQueryHandler;
|
||||
use Template\Handling\Product\Rule\ProductIdentifierAlreadyExistsRule;
|
||||
use Reinfi\DependencyInjection\Factory\AutoWiringFactory;
|
||||
use Reinfi\DependencyInjection\Factory\InjectionFactory;
|
||||
|
||||
return [
|
||||
'factories' => [
|
||||
|
||||
/// Builder
|
||||
ProductBuilder::class => AutoWiringFactory::class,
|
||||
|
||||
/// Rule
|
||||
ProductIdentifierAlreadyExistsRule::class => InjectionFactory::class,
|
||||
|
||||
/// CQRS
|
||||
// Product List
|
||||
ProductListQueryHandler::class => InjectionFactory::class,
|
||||
ProductListQueryBuilder::class => AutoWiringFactory::class,
|
||||
|
||||
// Create Product
|
||||
CreateProductCommandHandler::class => AutoWiringFactory::class,
|
||||
CreateProductCommandBuilder::class => AutoWiringFactory::class,
|
||||
|
||||
// Delete Product
|
||||
DeleteProductCommandHandler::class => InjectionFactory::class,
|
||||
DeleteProductCommandBuilder::class => AutoWiringFactory::class,
|
||||
|
||||
// Update Product
|
||||
UpdateProductCommandHandler::class => InjectionFactory::class,
|
||||
UpdateProductCommandBuilder::class => AutoWiringFactory::class,
|
||||
|
||||
],
|
||||
];
|
||||
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Handling\Product\Builder;
|
||||
|
||||
use Template\Data\Business\Entity\Product;
|
||||
|
||||
class ProductBuilder
|
||||
{
|
||||
public function build(
|
||||
string $identifier,
|
||||
?string $name,
|
||||
?string $url
|
||||
): Product
|
||||
{
|
||||
$product = new Product();
|
||||
|
||||
$product->setIdentifier($identifier);
|
||||
$product->setName($name);
|
||||
$product->setUrl($url);
|
||||
|
||||
return $product;
|
||||
}
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\Handling\Product;
|
||||
|
||||
class ConfigProvider
|
||||
{
|
||||
public function __invoke(): array
|
||||
{
|
||||
return [
|
||||
'dependencies' => require __DIR__ . '/./../config/service_manager.php',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Handling\Product\Exception;
|
||||
|
||||
use Template\Infrastructure\Exception\ErrorCode;
|
||||
use Template\Infrastructure\Exception\ErrorDomain;
|
||||
use Template\Infrastructure\Exception\Exception\TemplateException;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
class ProductNotFoundByIdException extends TemplateException {
|
||||
|
||||
private const MESSAGE = 'The product with the Id %s was not found!';
|
||||
|
||||
public function __construct(UuidInterface $id)
|
||||
{
|
||||
parent::__construct(
|
||||
sprintf(
|
||||
self::MESSAGE,
|
||||
$id->toString()
|
||||
),
|
||||
ErrorDomain::Product,
|
||||
ErrorCode::NotFound
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Handling\Product\Exception;
|
||||
|
||||
use Template\Infrastructure\Exception\ErrorCode;
|
||||
use Template\Infrastructure\Exception\ErrorDomain;
|
||||
use Template\Infrastructure\Exception\Exception\TemplateException;
|
||||
|
||||
class ProductWithIdentifierAlreadyExists extends TemplateException {
|
||||
|
||||
private const MESSAGE = 'A product with the identifier %s does already exist!';
|
||||
|
||||
public function __construct(string $identifier)
|
||||
{
|
||||
parent::__construct(
|
||||
sprintf(
|
||||
self::MESSAGE,
|
||||
$identifier
|
||||
),
|
||||
ErrorDomain::Product,
|
||||
ErrorCode::AlreadyExists
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Handling\Product\Handler\Command\CreateProduct;
|
||||
|
||||
class CreateProductCommand
|
||||
{
|
||||
public function __construct(
|
||||
private readonly string $identifier,
|
||||
private readonly ?string $name,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getIdentifier(): string {
|
||||
return $this->identifier;
|
||||
}
|
||||
|
||||
public function getName(): ?string {
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Handling\Product\Handler\Command\CreateProduct;
|
||||
|
||||
class CreateProductCommandBuilder
|
||||
{
|
||||
public function build(
|
||||
string $identifier,
|
||||
?string $name
|
||||
): CreateProductCommand
|
||||
{
|
||||
return new CreateProductCommand(
|
||||
$identifier,
|
||||
$name
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Handling\Product\Handler\Command\CreateProduct;
|
||||
|
||||
use Template\Data\Business\Entity\Product;
|
||||
use Template\Handling\Product\Builder\ProductBuilder;
|
||||
use Template\Handling\Product\Rule\ProductIdentifierAlreadyExistsRule;
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
|
||||
class CreateProductCommandHandler
|
||||
{
|
||||
public function __construct(
|
||||
private readonly TemplateEntityManager $entityManager,
|
||||
private readonly ProductIdentifierAlreadyExistsRule $productIdentifierAlreadyExistsRule,
|
||||
private readonly ProductBuilder $builder,
|
||||
) {
|
||||
}
|
||||
|
||||
public function execute(CreateProductCommand $command): Product
|
||||
{
|
||||
$this->productIdentifierAlreadyExistsRule->appliesTo($command->getIdentifier());
|
||||
|
||||
$product = $this->builder->build(
|
||||
identifier: $command->getIdentifier(),
|
||||
name: $command->getName(),
|
||||
url: null,
|
||||
);
|
||||
|
||||
$this->entityManager->persist($product);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $product;
|
||||
}
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Handling\Product\Handler\Command\DeleteProduct;
|
||||
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
class DeleteProductCommand
|
||||
{
|
||||
public function __construct(
|
||||
private readonly UuidInterface $id
|
||||
) {
|
||||
}
|
||||
|
||||
public function getId(): UuidInterface {
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Handling\Product\Handler\Command\DeleteProduct;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
|
||||
class DeleteProductCommandBuilder
|
||||
{
|
||||
public function build(
|
||||
string $id
|
||||
): DeleteProductCommand
|
||||
{
|
||||
return new DeleteProductCommand(
|
||||
id: Uuid::fromString($id)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Handling\Product\Handler\Command\DeleteProduct;
|
||||
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Template\Data\Business\Repository\ProductRepository;
|
||||
use Template\Handling\Product\Exception\ProductNotFoundByIdException;
|
||||
use Reinfi\DependencyInjection\Annotation\Inject;
|
||||
use Reinfi\DependencyInjection\Annotation\InjectDoctrineRepository;
|
||||
|
||||
class DeleteProductCommandHandler
|
||||
{
|
||||
/**
|
||||
* @Inject("Template\Data\Business\Manager\TemplateEntityManager")
|
||||
* @InjectDoctrineRepository(
|
||||
* entityManager="Template\Data\Business\Manager\TemplateEntityManager",
|
||||
* entity="Template\Data\Business\Entity\Product"
|
||||
* )
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly TemplateEntityManager $entityManager,
|
||||
private readonly ProductRepository $repository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function execute(DeleteProductCommand $command): void
|
||||
{
|
||||
$product = $this->repository->find(
|
||||
$command->getId()
|
||||
) ?? null;
|
||||
|
||||
if ($product === null) {
|
||||
throw new ProductNotFoundByIdException($command->getId());
|
||||
}
|
||||
|
||||
$this->entityManager->remove($product);
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Handling\Product\Handler\Command\UpdateProduct;
|
||||
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
class UpdateProductCommand
|
||||
{
|
||||
public function __construct(
|
||||
private readonly UuidInterface $id,
|
||||
private readonly string $identifier,
|
||||
private readonly ?string $name,
|
||||
private readonly ?string $url,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getId(): UuidInterface {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getIdentifier(): string {
|
||||
return $this->identifier;
|
||||
}
|
||||
|
||||
public function getName(): ?string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getUrl(): ?string {
|
||||
return $this->url;
|
||||
}
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Handling\Product\Handler\Command\UpdateProduct;
|
||||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
class UpdateProductCommandBuilder
|
||||
{
|
||||
public function build(
|
||||
string $id,
|
||||
string $identifier,
|
||||
?string $name,
|
||||
?string $url,
|
||||
): UpdateProductCommand
|
||||
{
|
||||
return new UpdateProductCommand(
|
||||
id: Uuid::fromString($id),
|
||||
identifier: $identifier,
|
||||
name: $name,
|
||||
url: $url === '' ? null : $url,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Handling\Product\Handler\Command\UpdateProduct;
|
||||
|
||||
use DateTime;
|
||||
use Template\Data\Business\Entity\Product;
|
||||
use Template\Data\Business\Repository\ProductRepository;
|
||||
use Template\Handling\Product\Exception\ProductNotFoundByIdException;
|
||||
use Template\Handling\Product\Rule\ProductIdentifierAlreadyExistsRule;
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Reinfi\DependencyInjection\Annotation\Inject;
|
||||
use Reinfi\DependencyInjection\Annotation\InjectDoctrineRepository;
|
||||
|
||||
class UpdateProductCommandHandler
|
||||
{
|
||||
/**
|
||||
* @Inject("Template\Data\Business\Manager\TemplateEntityManager")
|
||||
* @InjectDoctrineRepository(
|
||||
* entityManager="Template\Data\Business\Manager\TemplateEntityManager",
|
||||
* entity="Template\Data\Business\Entity\Product"
|
||||
* )
|
||||
* @Inject("Template\Handling\Product\Rule\ProductIdentifierAlreadyExistsRule")
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly TemplateEntityManager $entityManager,
|
||||
private readonly ProductRepository $repository,
|
||||
private readonly ProductIdentifierAlreadyExistsRule $productIdentifierAlreadyExistsRule,
|
||||
) {
|
||||
}
|
||||
|
||||
public function execute(UpdateProductCommand $command): Product
|
||||
{
|
||||
$id = $command->getId();
|
||||
|
||||
/** @var Product $product */
|
||||
$product = $this->repository->find($id) ?? null;
|
||||
if ($product === null) {
|
||||
throw new ProductNotFoundByIdException($id);
|
||||
}
|
||||
|
||||
if ($product->getId()->toString() !== $command->getId()->toString()) {
|
||||
$this->productIdentifierAlreadyExistsRule->appliesTo($command->getIdentifier());
|
||||
}
|
||||
|
||||
$product->setIdentifier($command->getIdentifier());
|
||||
$product->setName($command->getName());
|
||||
$product->setUrl($command->getUrl());
|
||||
$product->setUpdatedAt(new DateTime());
|
||||
|
||||
$this->entityManager->persist($product);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $product;
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Handling\Product\Handler\Query\ProductList;
|
||||
|
||||
class ProductListQuery
|
||||
{
|
||||
public function __construct(
|
||||
private readonly string $query
|
||||
) {
|
||||
}
|
||||
|
||||
public function getQuery(): string {
|
||||
return $this->query;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Handling\Product\Handler\Query\ProductList;
|
||||
|
||||
class ProductListQueryBuilder
|
||||
{
|
||||
public function __construct(
|
||||
) {
|
||||
}
|
||||
|
||||
public function build(
|
||||
string $query
|
||||
): ProductListQuery
|
||||
{
|
||||
return new ProductListQuery(
|
||||
$query
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Handling\Product\Handler\Query\ProductList;
|
||||
|
||||
use Template\Data\Business\Entity\Product;
|
||||
use Template\Data\Business\Repository\ProductRepository;
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Reinfi\DependencyInjection\Annotation\InjectDoctrineRepository;
|
||||
|
||||
class ProductListQueryHandler
|
||||
{
|
||||
/**
|
||||
* @InjectDoctrineRepository(
|
||||
* entityManager="Template\Data\Business\Manager\TemplateEntityManager",
|
||||
* entity="Template\Data\Business\Entity\Product"
|
||||
* )
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly ProductRepository $repository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function execute(ProductListQuery $query): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Handling\Product\Rule;
|
||||
|
||||
use Template\Data\Business\Entity\Product;
|
||||
use Template\Data\Business\Repository\ProductRepository;
|
||||
use Template\Handling\Product\Exception\ProductWithIdentifierAlreadyExists;
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Reinfi\DependencyInjection\Annotation\InjectDoctrineRepository;
|
||||
|
||||
class ProductIdentifierAlreadyExistsRule
|
||||
{
|
||||
/**
|
||||
* @InjectDoctrineRepository(
|
||||
* entityManager="Template\Data\Business\Manager\TemplateEntityManager",
|
||||
* entity="Template\Data\Business\Entity\Product"
|
||||
* )
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly ProductRepository $productRepository
|
||||
) {
|
||||
}
|
||||
|
||||
public function appliesTo(string $identifier) {
|
||||
$product = $this->productRepository->findOneBy([
|
||||
'identifier' => $identifier
|
||||
]) ?? null;
|
||||
|
||||
if ($product !== null) {
|
||||
throw new ProductWithIdentifierAlreadyExists($identifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -15,7 +15,7 @@ class LoadRegistrationStep implements TaskInterface
|
||||
{
|
||||
/**
|
||||
* @InjectDoctrineRepository(
|
||||
* entityManager="Template\Data\Business\Manager\TemplateEntityManager",
|
||||
* entityManager="Template\Data\Business\Manager\EntityManager",
|
||||
* entity="Template\Data\Business\Entity\Registration"
|
||||
* )
|
||||
*/
|
||||
|
||||
@ -4,14 +4,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace Template\Handling\Registration\Pipeline\ConfirmRegistration\Step;
|
||||
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Template\Data\Business\Manager\EntityManager;
|
||||
use teewurst\Pipeline\PipelineInterface;
|
||||
use teewurst\Pipeline\TaskInterface;
|
||||
|
||||
class SaveRegistrationAndUserStep implements TaskInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly TemplateEntityManager $entityManager,
|
||||
private readonly EntityManager $entityManager,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
@ -4,14 +4,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace Template\Handling\Registration\Pipeline\RegisterUser\Step;
|
||||
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Template\Data\Business\Manager\EntityManager;
|
||||
use teewurst\Pipeline\PipelineInterface;
|
||||
use teewurst\Pipeline\TaskInterface;
|
||||
|
||||
class SaveRegistrationStep implements TaskInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly TemplateEntityManager $entityManager,
|
||||
private readonly EntityManager $entityManager,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ class RegistrationWithIdentifierAlreadyExistsRule
|
||||
{
|
||||
/**
|
||||
* @InjectDoctrineRepository(
|
||||
* entityManager="Template\Data\Business\Manager\TemplateEntityManager",
|
||||
* entityManager="Template\Data\Business\Manager\EntityManager",
|
||||
* entity="Template\Data\Business\Entity\Registration"
|
||||
* )
|
||||
*/
|
||||
|
||||
@ -14,7 +14,7 @@ class UserBuilder
|
||||
{
|
||||
/**
|
||||
* @InjectDoctrineRepository(
|
||||
* entityManager="Template\Data\Business\Manager\TemplateEntityManager",
|
||||
* entityManager="Template\Data\Business\Manager\EntityManager",
|
||||
* entity="Template\Data\Business\Entity\Role"
|
||||
* )
|
||||
* @Inject("Template\Infrastructure\Encryption\Client\EncryptionClient")
|
||||
|
||||
@ -7,7 +7,7 @@ use Template\Data\Business\Repository\RoleRepository;
|
||||
use Template\Data\Business\Repository\UserRepository;
|
||||
use Template\Handling\User\Exception\UserNotFoundByIdentifierException;
|
||||
use Template\Handling\User\Exception\UserWrongPasswordException;
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Template\Data\Business\Manager\EntityManager;
|
||||
use Template\Infrastructure\Encryption\Client\EncryptionClient;
|
||||
use Reinfi\DependencyInjection\Annotation\Inject;
|
||||
use Reinfi\DependencyInjection\Annotation\InjectDoctrineRepository;
|
||||
@ -15,7 +15,7 @@ use Reinfi\DependencyInjection\Annotation\InjectDoctrineRepository;
|
||||
class ChangePasswordCommandHandler
|
||||
{
|
||||
public function __construct(
|
||||
private readonly TemplateEntityManager $entityManager,
|
||||
private readonly EntityManager $entityManager,
|
||||
private readonly EncryptionClient $encryptionClient
|
||||
) {
|
||||
}
|
||||
|
||||
@ -3,13 +3,13 @@
|
||||
namespace Template\Handling\User\Handler\Command\ChangeUsername;
|
||||
|
||||
use Template\Handling\User\Exception\UserWrongPasswordException;
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Template\Data\Business\Manager\EntityManager;
|
||||
use Template\Infrastructure\Encryption\Client\EncryptionClient;
|
||||
|
||||
class ChangeUsernameCommandHandler
|
||||
{
|
||||
public function __construct(
|
||||
private readonly TemplateEntityManager $entityManager,
|
||||
private readonly EntityManager $entityManager,
|
||||
private readonly EncryptionClient $encryptionClient
|
||||
) {
|
||||
}
|
||||
|
||||
@ -5,13 +5,13 @@ namespace Template\Handling\User\Handler\Command\CreateUser;
|
||||
use Template\Data\Business\Entity\User;
|
||||
use Template\Handling\User\Builder\UserBuilder;
|
||||
use Template\Handling\User\Rule\UserWithIdentifierAlreadyExistsRule;
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Template\Data\Business\Manager\EntityManager;
|
||||
use Reinfi\DependencyInjection\Annotation\Inject;
|
||||
|
||||
class CreateUserCommandHandler
|
||||
{
|
||||
public function __construct(
|
||||
private readonly TemplateEntityManager $entityManager,
|
||||
private readonly EntityManager $entityManager,
|
||||
private readonly UserBuilder $builder,
|
||||
private readonly UserWithIdentifierAlreadyExistsRule $userWithIdentifierAlreadyExistsRule
|
||||
) {
|
||||
|
||||
@ -10,7 +10,7 @@ class UserWithIdentifierAlreadyExistsRule
|
||||
{
|
||||
/**
|
||||
* @InjectDoctrineRepository(
|
||||
* entityManager="Template\Data\Business\Manager\TemplateEntityManager",
|
||||
* entityManager="Template\Data\Business\Manager\EntityManager",
|
||||
* entity="Template\Data\Business\Entity\User"
|
||||
* )
|
||||
*/
|
||||
|
||||
@ -9,26 +9,26 @@ use Template\Data\Business\Repository\UserSessionRepository;
|
||||
use Template\Handling\User\Exception\UserNotFoundByIdentifierException;
|
||||
use Template\Handling\User\Exception\UserWrongPasswordException;
|
||||
use Template\Handling\UserSession\Rule\UserPasswordMatchesRule;
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Template\Data\Business\Manager\EntityManager;
|
||||
use Reinfi\DependencyInjection\Annotation\Inject;
|
||||
use Reinfi\DependencyInjection\Annotation\InjectDoctrineRepository;
|
||||
|
||||
class LoginUserCommandHandler
|
||||
{
|
||||
/**
|
||||
* @Inject("Template\Data\Business\Manager\TemplateEntityManager")
|
||||
* @Inject("Template\Data\Business\Manager\EntityManager")
|
||||
* @InjectDoctrineRepository(
|
||||
* entityManager="Template\Data\Business\Manager\TemplateEntityManager",
|
||||
* entityManager="Template\Data\Business\Manager\EntityManager",
|
||||
* entity="Template\Data\Business\Entity\User"
|
||||
* )
|
||||
* @InjectDoctrineRepository(
|
||||
* entityManager="Template\Data\Business\Manager\TemplateEntityManager",
|
||||
* entityManager="Template\Data\Business\Manager\EntityManager",
|
||||
* entity="Template\Data\Business\Entity\UserSession"
|
||||
* )
|
||||
* @Inject("Template\Handling\UserSession\Rule\UserPasswordMatchesRule")
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly TemplateEntityManager $entityManager,
|
||||
private readonly EntityManager $entityManager,
|
||||
private readonly UserRepository $userRepository,
|
||||
private readonly UserSessionRepository $userSessionRepository,
|
||||
private readonly UserPasswordMatchesRule $passwordMatchesRule
|
||||
|
||||
@ -4,7 +4,7 @@ namespace Template\Handling\UserSession\Handler\Command\LogoutUser;
|
||||
|
||||
use Template\Data\Business\Entity\UserSession;
|
||||
use Template\Data\Business\Repository\UserSessionRepository;
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Template\Data\Business\Manager\EntityManager;
|
||||
use Reinfi\DependencyInjection\Annotation\Inject;
|
||||
use Reinfi\DependencyInjection\Annotation\InjectDoctrineRepository;
|
||||
|
||||
@ -12,14 +12,14 @@ class LogoutUserCommandHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* @Inject("Template\Data\Business\Manager\TemplateEntityManager")
|
||||
* @Inject("Template\Data\Business\Manager\EntityManager")
|
||||
* @InjectDoctrineRepository(
|
||||
* entityManager="Template\Data\Business\Manager\TemplateEntityManager",
|
||||
* entityManager="Template\Data\Business\Manager\EntityManager",
|
||||
* entity="Template\Data\Business\Entity\UserSession"
|
||||
* )
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly TemplateEntityManager $entityManager,
|
||||
private readonly EntityManager $entityManager,
|
||||
private readonly UserSessionRepository $userSessionRepository
|
||||
) {
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ namespace Template\Infrastructure\Session\Middleware;
|
||||
use Template\Data\Business\Entity\UserSession;
|
||||
use Template\Data\Business\Repository\UserSessionRepository;
|
||||
use Template\Handling\UserSession\Builder\UserSessionBuilder;
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Template\Data\Business\Manager\EntityManager;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
@ -19,7 +19,7 @@ class SessionMiddleware implements MiddlewareInterface
|
||||
private readonly UserSessionRepository $userSessionRepository;
|
||||
|
||||
public function __construct(
|
||||
private readonly TemplateEntityManager $entityManager,
|
||||
private readonly EntityManager $entityManager,
|
||||
private readonly UserSessionBuilder $userSessionBuilder,
|
||||
) {
|
||||
$this->userSessionRepository = $this->entityManager->getRepository(UserSession::class);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user