first commit
This commit is contained in:
parent
721dfc58d1
commit
8d896bcd12
15
.env.example
15
.env.example
@ -1,20 +1,13 @@
|
||||
# DB Configuration
|
||||
DB_DRIVER=pdo_mysql
|
||||
DB_HOST=template-backend-mysql
|
||||
DB_HOST=myTube-backend-mysql
|
||||
DB_PORT=3306
|
||||
DB_USER=template
|
||||
DB_USER=myTube
|
||||
DB_PASSWORD=pass
|
||||
DB_NAME=template
|
||||
DB_NAME=myTube
|
||||
DB_NAME_LOG=log
|
||||
|
||||
# API Keys
|
||||
AUTH_API_KEY=
|
||||
NOTIFICATION_API_KEY=
|
||||
FILE_API_KEY=
|
||||
HOMEPAGE_API_KEY=
|
||||
BEE_API_KEY=
|
||||
|
||||
# Template Setup
|
||||
# MyTube Setup
|
||||
INIT_USER_NAME=admin
|
||||
INIT_USER_PASSWORD=password
|
||||
INIT_USER_MAIL=admin@test.com
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Template\Infrastructure\Logging\Logger\Logger;
|
||||
use MyTube\Infrastructure\Logging\Logger\Logger;
|
||||
use Symfony\Component\Console\Application;
|
||||
|
||||
require_once __DIR__ . '/../config/autoload/defines.php';
|
||||
|
||||
155
bin/createApi.php
Normal file
155
bin/createApi.php
Normal file
@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
if (count($argv) !== 6) {
|
||||
echo 'Use of this Command:' . PHP_EOL
|
||||
. 'createApi API_IsExternal API_Namespace API_Name CQRS_IsCommand CQRS_Namespace' . PHP_EOL;
|
||||
die;
|
||||
}
|
||||
|
||||
$projectSourceDirectory = 'src/';
|
||||
$projectNamespace = 'MyTube';
|
||||
|
||||
$apiType = strtolower($argv[1]) === 'true' ? 'External' : 'Internal';
|
||||
$apiNamespace = $argv[2];
|
||||
$apiName = $argv[3];
|
||||
$cqrsType = strtolower($argv[4]) === 'true' ? 'Command' : 'Query';
|
||||
$cqrsNamespace = $argv[5];
|
||||
|
||||
# API Handler
|
||||
$apiHandlerName = $apiName . 'Handler';
|
||||
$apiHandlerNamespace = $projectNamespace . '\\API\\' . $apiType . '\\' . $apiNamespace . '\\Handler';
|
||||
$apiHandlerFilePath = $projectSourceDirectory . 'ApiDomain/' . $apiType . '/' . $apiNamespace . '/src/Handler/' . $apiHandlerName . '.php';
|
||||
|
||||
# CQRS
|
||||
$cqrsFilePath = $projectSourceDirectory . 'HandlingDomain/' . $cqrsNamespace . '/src/Handler/' . $cqrsType . '/' . $apiName . '/';
|
||||
$cqrsName = $apiName . $cqrsType;
|
||||
$cqrsVariableName = lcfirst($cqrsName);
|
||||
$cqrsNamespace = $projectNamespace . '\\Handling\\' . $cqrsNamespace . '\\Handler\\' . $cqrsType . '\\' . $apiName;
|
||||
|
||||
# Command / Query
|
||||
$cqrsPath = $cqrsFilePath . $cqrsName . '.php';
|
||||
$cqrsUsingNamespace = $cqrsNamespace . '\\' . $cqrsName;
|
||||
|
||||
# Handler
|
||||
$cqrsHandlerName = $cqrsName . 'Handler';
|
||||
$cqrsHandlerVariableName = lcfirst($cqrsHandlerName);
|
||||
$cqrsHandlerPath = $cqrsFilePath . $cqrsName . 'Handler' . '.php';
|
||||
$cqrsHandlerUsingNamespace = $cqrsNamespace . '\\' . $cqrsHandlerName;
|
||||
|
||||
# Builder
|
||||
$cqrsBuilderName = $cqrsName . 'Builder';
|
||||
$cqrsBuilderVariableName = lcfirst($cqrsBuilderName);
|
||||
$cqrsBuilderPath = $cqrsFilePath . $cqrsName . 'Builder' . '.php';
|
||||
$cqrsBuilderUsingNamespace = $cqrsNamespace . '\\' . $cqrsBuilderName;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
########## WRITE FILES ###############
|
||||
function writeToFile($path, $content) {
|
||||
echo 'Writing contents to file ' . $path . PHP_EOL;
|
||||
|
||||
$directory = pathinfo($path, PATHINFO_DIRNAME);
|
||||
if (!is_dir($directory)) {
|
||||
mkdir($directory, 0755, true);
|
||||
}
|
||||
|
||||
file_put_contents($path, $content);
|
||||
}
|
||||
|
||||
$apiHandlerFileContent = "<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace {$apiHandlerNamespace};
|
||||
|
||||
use {$cqrsHandlerUsingNamespace};
|
||||
use {$cqrsBuilderUsingNamespace};
|
||||
use Psr\\Http\\Message\\ResponseInterface;
|
||||
use Psr\\Http\\Message\\ServerRequestInterface;
|
||||
use Psr\\Http\\Server\\RequestHandlerInterface;
|
||||
use Bee\\Infrastructure\\Response\\SuccessResponse;
|
||||
|
||||
class {$apiHandlerName} implements RequestHandlerInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly {$cqrsHandlerName} \${$cqrsHandlerVariableName},
|
||||
private readonly {$cqrsBuilderName} \${$cqrsBuilderVariableName},
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(ServerRequestInterface \$request): ResponseInterface
|
||||
{
|
||||
\$data = json_decode(
|
||||
\$request->getBody()->getContents(),
|
||||
true
|
||||
);
|
||||
|
||||
\${$cqrsVariableName} = \$this->{$cqrsBuilderVariableName}->build(
|
||||
\$data
|
||||
);
|
||||
\$result = \$this->{$cqrsHandlerVariableName}->execute(\${$cqrsVariableName});
|
||||
|
||||
return new SuccessResponse('OK');
|
||||
}
|
||||
}
|
||||
";
|
||||
writeToFile($apiHandlerFilePath, $apiHandlerFileContent);
|
||||
|
||||
$cqrsFileContent = "<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace {$cqrsNamespace};
|
||||
|
||||
class {$cqrsName}
|
||||
{
|
||||
public function __construct(
|
||||
#TODO
|
||||
) {
|
||||
}
|
||||
|
||||
#TODO
|
||||
}
|
||||
";
|
||||
writeToFile($cqrsPath, $cqrsFileContent);
|
||||
|
||||
$cqrsHandlerFileContent = "<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace {$cqrsNamespace};
|
||||
|
||||
class {$cqrsHandlerName}
|
||||
{
|
||||
public function __construct(
|
||||
#TODO
|
||||
) {
|
||||
}
|
||||
|
||||
public function execute({$cqrsName} \${$cqrsVariableName}): void
|
||||
{
|
||||
}
|
||||
}
|
||||
";
|
||||
writeToFile($cqrsHandlerPath, $cqrsHandlerFileContent);
|
||||
|
||||
$cqrsBuilderFileContent = "<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace {$cqrsNamespace};
|
||||
|
||||
class {$cqrsBuilderName}
|
||||
{
|
||||
public function build(
|
||||
#TODO
|
||||
): {$cqrsName} {
|
||||
return new {$cqrsName}(
|
||||
#TODO
|
||||
);
|
||||
}
|
||||
}
|
||||
";
|
||||
writeToFile($cqrsBuilderPath, $cqrsBuilderFileContent);
|
||||
149
bin/createPipeline.php
Normal file
149
bin/createPipeline.php
Normal file
@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
if (count($argv) < 4) {
|
||||
echo 'Use of this Command:' . PHP_EOL
|
||||
. 'createPipeline Handling_Namespace Pipeline_Name Step_1_Name Step_2_Name' . PHP_EOL;
|
||||
die;
|
||||
}
|
||||
|
||||
$projectSourceDirectory = 'src/';
|
||||
$projectNamespace = 'MyTube';
|
||||
|
||||
$pipelineNamespace = $argv[1];
|
||||
$pipelineName = $argv[2];
|
||||
$stepNames = array_slice($argv, 3);
|
||||
|
||||
# Pipeline
|
||||
$pipelineClassName = $pipelineName . 'Pipeline';
|
||||
$pipelineVariableName = lcfirst($pipelineClassName);
|
||||
$pipelineFilePath = $projectSourceDirectory . 'HandlingDomain/' . $pipelineNamespace . '/src/Pipeline/' . $pipelineName . '/' . $pipelineClassName . '.php';
|
||||
$pipelineFullNamespace = $projectNamespace . '\\Handling\\' . $pipelineNamespace . '\\Pipeline\\' . $pipelineName;
|
||||
$pipelineUsingNamespace = $pipelineFullNamespace . '\\' . $pipelineClassName;
|
||||
|
||||
# Payload
|
||||
$payloadClassName = $pipelineName . 'Payload';
|
||||
$payloadVariableName = lcfirst($payloadClassName);
|
||||
$payloadFilePath = $projectSourceDirectory . 'HandlingDomain/' . $pipelineNamespace . '/src/Pipeline/' . $pipelineName . '/' . $payloadClassName . '.php';
|
||||
$payloadFullNamespace = $projectNamespace . '\\Handling\\' . $pipelineNamespace . '\\Pipeline\\' . $pipelineName;
|
||||
$payloadUsingNamespace = $payloadFullNamespace . '\\' . $payloadClassName;
|
||||
|
||||
# Step
|
||||
$stepsFilePath = $projectSourceDirectory . 'HandlingDomain/' . $pipelineNamespace . '/src/Pipeline/' . $pipelineName . '/Step/';
|
||||
$stepsFullNamespace = $projectNamespace . '\\Handling\\' . $pipelineNamespace . '\\Pipeline\\' . $pipelineName . '\\Step';
|
||||
|
||||
$steps = [];
|
||||
foreach ($stepNames as $stepName) {
|
||||
$stepClassName = $stepName . 'Step';
|
||||
$steps[] = [
|
||||
'stepClassName' => $stepClassName,
|
||||
'stepVariableName' => lcfirst($stepClassName),
|
||||
'stepFilePath' => $stepsFilePath . $stepClassName . '.php',
|
||||
'stepUsingNamespace' => 'use ' . $payloadFullNamespace . '\\Step\\' . $stepClassName,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
########## WRITE FILES ###############
|
||||
function writeToFile($path, $content) {
|
||||
echo 'Writing contents to file ' . $path . PHP_EOL;
|
||||
|
||||
$directory = pathinfo($path, PATHINFO_DIRNAME);
|
||||
if (!is_dir($directory)) {
|
||||
mkdir($directory, 0755, true);
|
||||
}
|
||||
|
||||
file_put_contents($path, $content);
|
||||
}
|
||||
|
||||
$stepsUsingNamespaces = [];
|
||||
$stepsDeclarations = [];
|
||||
$stepsReferences = [];
|
||||
|
||||
foreach ($steps as $step) {
|
||||
$stepClassName = $step['stepClassName'];
|
||||
$stepVariableName = $step['stepVariableName'];
|
||||
$stepFilePath = $step['stepFilePath'];
|
||||
$stepUsingNamespace = $step['stepUsingNamespace'];
|
||||
|
||||
$stepsUsingNamespaces[] = $stepUsingNamespace . ';';
|
||||
$stepsDeclarations[] = 'private readonly ' . $stepClassName . ' $' . $stepVariableName . ',';
|
||||
$stepsReferences[] = '$this->' . $stepVariableName . ',';
|
||||
|
||||
$stepFileContent = "<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace {$stepsFullNamespace};
|
||||
|
||||
use {$payloadUsingNamespace};
|
||||
|
||||
use teewurst\\Pipeline\\PipelineInterface;
|
||||
use teewurst\\Pipeline\\TaskInterface;
|
||||
|
||||
class {$stepClassName} implements TaskInterface
|
||||
{
|
||||
public function __construct(
|
||||
#TODO
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke(
|
||||
\$payload,
|
||||
PipelineInterface \$pipeline
|
||||
): void
|
||||
{
|
||||
/** @var {$payloadClassName} \${$payloadVariableName} */
|
||||
\${$payloadVariableName} = \$payload;
|
||||
|
||||
\$pipeline->next()(\$payload, \$pipeline);
|
||||
}
|
||||
}
|
||||
";
|
||||
writeToFile($stepFilePath, $stepFileContent);
|
||||
}
|
||||
|
||||
$stepsUsingNamespace = implode(PHP_EOL, $stepsUsingNamespaces);
|
||||
$stepsDeclaration = implode(PHP_EOL . ' ', $stepsDeclarations);
|
||||
$stepsReference = implode(PHP_EOL . ' ', $stepsReferences);
|
||||
|
||||
|
||||
|
||||
$pipelineFileContent = "<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace {$pipelineFullNamespace};
|
||||
|
||||
{$stepsUsingNamespace}
|
||||
use teewurst\\Pipeline\\Pipeline;
|
||||
|
||||
class {$pipelineClassName} extends Pipeline
|
||||
{
|
||||
public function __construct(
|
||||
{$stepsDeclaration}
|
||||
) {
|
||||
parent::__construct([
|
||||
{$stepsReference}
|
||||
]);
|
||||
}
|
||||
}
|
||||
";
|
||||
writeToFile($pipelineFilePath, $pipelineFileContent);
|
||||
|
||||
$payloadFileContent = "<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace {$payloadFullNamespace};
|
||||
|
||||
class {$payloadClassName}
|
||||
{
|
||||
public function __construct(
|
||||
#TODO
|
||||
) {
|
||||
}
|
||||
}
|
||||
";
|
||||
writeToFile($payloadFilePath, $payloadFileContent);
|
||||
@ -3,7 +3,7 @@
|
||||
require_once __DIR__ . '/../config/autoload/defines.php';
|
||||
require APP_ROOT . '/vendor/autoload.php';
|
||||
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use MyTube\Data\Business\Manager\MyTubeEntityManager;
|
||||
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(MyTubeEntityManager::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 MyTube\Data\Business\Manager\MyTubeEntityManager;
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
use Doctrine\Migrations\Configuration\Configuration;
|
||||
@ -30,17 +30,17 @@ $isDevMode = true;
|
||||
$container = require APP_ROOT . '/config/container.php';
|
||||
$config = $container->get('config');
|
||||
$doctrineConfig = $config['doctrine'];
|
||||
$paths = $doctrineConfig['driver']['orm_template_annotation_driver']['paths'];
|
||||
$paths = $doctrineConfig['driver']['orm_myTube_annotation_driver']['paths'];
|
||||
|
||||
$dbParams = $doctrineConfig['connection']['orm_template']['params'];
|
||||
$migrationsConf = $doctrineConfig['migrations_configuration']['orm_template'];
|
||||
$dbParams = $doctrineConfig['connection']['orm_myTube']['params'];
|
||||
$migrationsConf = $doctrineConfig['migrations_configuration']['orm_myTube'];
|
||||
|
||||
$reader = new AnnotationReader();
|
||||
$driver = new AnnotationDriver($reader, $paths);
|
||||
|
||||
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
|
||||
$config->setMetadataDriverImpl($driver);
|
||||
$entityManager = $container->get(TemplateEntityManager::class);
|
||||
$entityManager = $container->get(MyTubeEntityManager::class);
|
||||
|
||||
try {
|
||||
$connection = DriverManager::getConnection($dbParams);
|
||||
|
||||
@ -21,12 +21,12 @@ $SCRIPT_DIR/exec up -d
|
||||
source $ENV_DIR/bin/script/drun
|
||||
|
||||
# Install PHP packages
|
||||
drun template-backend composer install
|
||||
drun myTube-backend composer install
|
||||
|
||||
# Migrate databases to current version
|
||||
drun template-backend composer dmm
|
||||
drun template-backend composer dmlm
|
||||
drun myTube-backend composer dmm
|
||||
drun myTube-backend composer dmlm
|
||||
|
||||
# Insert setup for project after this line
|
||||
drun template-backend composer console rbac:update
|
||||
drun template-backend composer console init:data
|
||||
drun myTube-backend composer console rbac:update
|
||||
drun myTube-backend composer console init:data
|
||||
@ -19,50 +19,50 @@
|
||||
"monolog\/monolog": "^3.4",
|
||||
"laminas\/laminas-mail": "^2.23",
|
||||
"teewurst\/pipeline": "^3.0",
|
||||
"guzzlehttp\/guzzle": "^7.8"
|
||||
"guzzlehttp\/guzzle": "^7.8",
|
||||
"micilini\/video-stream": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Template\\API\\Console\\": "src\/ApiDomain\/Console\/src",
|
||||
"Template\\API\\External\\Authentication\\": "src\/ApiDomain\/External\/Authentication\/src",
|
||||
"Template\\API\\External\\Health\\": "src\/ApiDomain\/External\/Health\/src",
|
||||
"Template\\API\\External\\Product\\": "src\/ApiDomain\/External\/Product\/src",
|
||||
"Template\\API\\External\\User\\": "src\/ApiDomain\/External\/User\/src",
|
||||
"Template\\Data\\Business\\": "src\/DataDomain\/Business\/src",
|
||||
"Template\\Data\\Log\\": "src\/DataDomain\/Log\/src",
|
||||
"Template\\Handling\\Product\\": "src\/HandlingDomain\/Product\/src",
|
||||
"Template\\Handling\\Registration\\": "src\/HandlingDomain\/Registration\/src",
|
||||
"Template\\Handling\\Role\\": "src\/HandlingDomain\/Role\/src",
|
||||
"Template\\Handling\\User\\": "src\/HandlingDomain\/User\/src",
|
||||
"Template\\Handling\\UserSession\\": "src\/HandlingDomain\/UserSession\/src",
|
||||
"Template\\Infrastructure\\Database\\": "src\/Infrastructure\/Database\/src",
|
||||
"Template\\Infrastructure\\DependencyInjection\\": "src\/Infrastructure\/DependencyInjection\/src",
|
||||
"Template\\Infrastructure\\Encryption\\": "src\/Infrastructure\/Encryption\/src",
|
||||
"Template\\Infrastructure\\Exception\\": "src\/Infrastructure\/Exception\/src",
|
||||
"Template\\Infrastructure\\Logging\\": "src\/Infrastructure\/Logging\/src",
|
||||
"Template\\Infrastructure\\Rbac\\": "src\/Infrastructure\/Rbac\/src",
|
||||
"Template\\Infrastructure\\Request\\": "src\/Infrastructure\/Request\/src",
|
||||
"Template\\Infrastructure\\Response\\": "src\/Infrastructure\/Response\/src",
|
||||
"Template\\Infrastructure\\Session\\": "src\/Infrastructure\/Session\/src",
|
||||
"Template\\Infrastructure\\UuidGenerator\\": "src\/Infrastructure\/UuidGenerator\/src"
|
||||
"MyTube\\API\\Console\\": "src\/ApiDomain\/Console\/src",
|
||||
"MyTube\\API\\External\\Authentication\\": "src\/ApiDomain\/External\/Authentication\/src",
|
||||
"MyTube\\API\\External\\Health\\": "src\/ApiDomain\/External\/Health\/src",
|
||||
"MyTube\\API\\External\\User\\": "src\/ApiDomain\/External\/User\/src",
|
||||
"MyTube\\Data\\Business\\": "src\/DataDomain\/Business\/src",
|
||||
"MyTube\\Data\\Log\\": "src\/DataDomain\/Log\/src",
|
||||
"MyTube\\Handling\\Product\\": "src\/HandlingDomain\/Product\/src",
|
||||
"MyTube\\Handling\\Registration\\": "src\/HandlingDomain\/Registration\/src",
|
||||
"MyTube\\Handling\\Role\\": "src\/HandlingDomain\/Role\/src",
|
||||
"MyTube\\Handling\\User\\": "src\/HandlingDomain\/User\/src",
|
||||
"MyTube\\Handling\\UserSession\\": "src\/HandlingDomain\/UserSession\/src",
|
||||
"MyTube\\Infrastructure\\Database\\": "src\/Infrastructure\/Database\/src",
|
||||
"MyTube\\Infrastructure\\DependencyInjection\\": "src\/Infrastructure\/DependencyInjection\/src",
|
||||
"MyTube\\Infrastructure\\Encryption\\": "src\/Infrastructure\/Encryption\/src",
|
||||
"MyTube\\Infrastructure\\Exception\\": "src\/Infrastructure\/Exception\/src",
|
||||
"MyTube\\Infrastructure\\Logging\\": "src\/Infrastructure\/Logging\/src",
|
||||
"MyTube\\Infrastructure\\Rbac\\": "src\/Infrastructure\/Rbac\/src",
|
||||
"MyTube\\Infrastructure\\Request\\": "src\/Infrastructure\/Request\/src",
|
||||
"MyTube\\Infrastructure\\Response\\": "src\/Infrastructure\/Response\/src",
|
||||
"MyTube\\Infrastructure\\Session\\": "src\/Infrastructure\/Session\/src",
|
||||
"MyTube\\Infrastructure\\UuidGenerator\\": "src\/Infrastructure\/UuidGenerator\/src"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"teewurst\/psr4-advanced-wildcard-composer-plugin": {
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Template\\API\\%s\\%s\\": "src\/ApiDomain\/{*}\/{*}\/src\/",
|
||||
"Template\\Data\\%s\\": "src\/DataDomain\/{*}\/src\/",
|
||||
"Template\\Handling\\%s\\": "src\/HandlingDomain\/{*}\/src\/",
|
||||
"Template\\Infrastructure\\%s\\": "src\/Infrastructure\/{*}\/src\/"
|
||||
"MyTube\\API\\%s\\%s\\": "src\/ApiDomain\/{*}\/{*}\/src\/",
|
||||
"MyTube\\Data\\%s\\": "src\/DataDomain\/{*}\/src\/",
|
||||
"MyTube\\Handling\\%s\\": "src\/HandlingDomain\/{*}\/src\/",
|
||||
"MyTube\\Infrastructure\\%s\\": "src\/Infrastructure\/{*}\/src\/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Template\\API\\%s\\%s\\": "src\/ApiDomain\/{*}\/{*}\/src\/",
|
||||
"Template\\Data\\%s\\": "src\/DataDomain\/{*}\/src\/",
|
||||
"Template\\Handling\\%s\\": "src\/HandlingDomain\/{*}\/src\/",
|
||||
"Template\\Infrastructure\\%s\\": "src\/Infrastructure\/{*}\/src\/"
|
||||
"MyTube\\API\\%s\\%s\\": "src\/ApiDomain\/{*}\/{*}\/src\/",
|
||||
"MyTube\\Data\\%s\\": "src\/DataDomain\/{*}\/src\/",
|
||||
"MyTube\\Handling\\%s\\": "src\/HandlingDomain\/{*}\/src\/",
|
||||
"MyTube\\Infrastructure\\%s\\": "src\/Infrastructure\/{*}\/src\/"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -96,27 +96,26 @@
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Template\\API\\External\\Authentication\\": "src\/ApiDomain\/External\/Authentication\/src",
|
||||
"Template\\API\\External\\Health\\": "src\/ApiDomain\/External\/Health\/src",
|
||||
"Template\\API\\External\\Product\\": "src\/ApiDomain\/External\/Product\/src",
|
||||
"Template\\API\\External\\User\\": "src\/ApiDomain\/External\/User\/src",
|
||||
"Template\\Data\\Business\\": "src\/DataDomain\/Business\/src",
|
||||
"Template\\Data\\Log\\": "src\/DataDomain\/Log\/src",
|
||||
"Template\\Handling\\Product\\": "src\/HandlingDomain\/Product\/src",
|
||||
"Template\\Handling\\Registration\\": "src\/HandlingDomain\/Registration\/src",
|
||||
"Template\\Handling\\Role\\": "src\/HandlingDomain\/Role\/src",
|
||||
"Template\\Handling\\User\\": "src\/HandlingDomain\/User\/src",
|
||||
"Template\\Handling\\UserSession\\": "src\/HandlingDomain\/UserSession\/src",
|
||||
"Template\\Infrastructure\\Database\\": "src\/Infrastructure\/Database\/src",
|
||||
"Template\\Infrastructure\\DependencyInjection\\": "src\/Infrastructure\/DependencyInjection\/src",
|
||||
"Template\\Infrastructure\\Encryption\\": "src\/Infrastructure\/Encryption\/src",
|
||||
"Template\\Infrastructure\\Exception\\": "src\/Infrastructure\/Exception\/src",
|
||||
"Template\\Infrastructure\\Logging\\": "src\/Infrastructure\/Logging\/src",
|
||||
"Template\\Infrastructure\\Rbac\\": "src\/Infrastructure\/Rbac\/src",
|
||||
"Template\\Infrastructure\\Request\\": "src\/Infrastructure\/Request\/src",
|
||||
"Template\\Infrastructure\\Response\\": "src\/Infrastructure\/Response\/src",
|
||||
"Template\\Infrastructure\\Session\\": "src\/Infrastructure\/Session\/src",
|
||||
"Template\\Infrastructure\\UuidGenerator\\": "src\/Infrastructure\/UuidGenerator\/src"
|
||||
"MyTube\\API\\External\\Authentication\\": "src\/ApiDomain\/External\/Authentication\/src",
|
||||
"MyTube\\API\\External\\Health\\": "src\/ApiDomain\/External\/Health\/src",
|
||||
"MyTube\\API\\External\\User\\": "src\/ApiDomain\/External\/User\/src",
|
||||
"MyTube\\Data\\Business\\": "src\/DataDomain\/Business\/src",
|
||||
"MyTube\\Data\\Log\\": "src\/DataDomain\/Log\/src",
|
||||
"MyTube\\Handling\\Product\\": "src\/HandlingDomain\/Product\/src",
|
||||
"MyTube\\Handling\\Registration\\": "src\/HandlingDomain\/Registration\/src",
|
||||
"MyTube\\Handling\\Role\\": "src\/HandlingDomain\/Role\/src",
|
||||
"MyTube\\Handling\\User\\": "src\/HandlingDomain\/User\/src",
|
||||
"MyTube\\Handling\\UserSession\\": "src\/HandlingDomain\/UserSession\/src",
|
||||
"MyTube\\Infrastructure\\Database\\": "src\/Infrastructure\/Database\/src",
|
||||
"MyTube\\Infrastructure\\DependencyInjection\\": "src\/Infrastructure\/DependencyInjection\/src",
|
||||
"MyTube\\Infrastructure\\Encryption\\": "src\/Infrastructure\/Encryption\/src",
|
||||
"MyTube\\Infrastructure\\Exception\\": "src\/Infrastructure\/Exception\/src",
|
||||
"MyTube\\Infrastructure\\Logging\\": "src\/Infrastructure\/Logging\/src",
|
||||
"MyTube\\Infrastructure\\Rbac\\": "src\/Infrastructure\/Rbac\/src",
|
||||
"MyTube\\Infrastructure\\Request\\": "src\/Infrastructure\/Request\/src",
|
||||
"MyTube\\Infrastructure\\Response\\": "src\/Infrastructure\/Response\/src",
|
||||
"MyTube\\Infrastructure\\Session\\": "src\/Infrastructure\/Session\/src",
|
||||
"MyTube\\Infrastructure\\UuidGenerator\\": "src\/Infrastructure\/UuidGenerator\/src"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -19,29 +19,30 @@
|
||||
"monolog/monolog": "^3.4",
|
||||
"laminas/laminas-mail": "^2.23",
|
||||
"teewurst/pipeline": "^3.0",
|
||||
"guzzlehttp/guzzle": "^7.8"
|
||||
"guzzlehttp/guzzle": "^7.8",
|
||||
"micilini/video-stream": "^1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Template\\API\\Console\\": "src/ApiDomain/Console/src/"
|
||||
"MyTube\\API\\Console\\": "src/ApiDomain/Console/src/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"teewurst/psr4-advanced-wildcard-composer-plugin": {
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Template\\API\\%s\\%s\\": "src/ApiDomain/{*}/{*}/src/",
|
||||
"Template\\Data\\%s\\": "src/DataDomain/{*}/src/",
|
||||
"Template\\Handling\\%s\\": "src/HandlingDomain/{*}/src/",
|
||||
"Template\\Infrastructure\\%s\\": "src/Infrastructure/{*}/src/"
|
||||
"MyTube\\API\\%s\\%s\\": "src/ApiDomain/{*}/{*}/src/",
|
||||
"MyTube\\Data\\%s\\": "src/DataDomain/{*}/src/",
|
||||
"MyTube\\Handling\\%s\\": "src/HandlingDomain/{*}/src/",
|
||||
"MyTube\\Infrastructure\\%s\\": "src/Infrastructure/{*}/src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Template\\API\\%s\\%s\\": "src/ApiDomain/{*}/{*}/src/",
|
||||
"Template\\Data\\%s\\": "src/DataDomain/{*}/src/",
|
||||
"Template\\Handling\\%s\\": "src/HandlingDomain/{*}/src/",
|
||||
"Template\\Infrastructure\\%s\\": "src/Infrastructure/{*}/src/"
|
||||
"MyTube\\API\\%s\\%s\\": "src/ApiDomain/{*}/{*}/src/",
|
||||
"MyTube\\Data\\%s\\": "src/DataDomain/{*}/src/",
|
||||
"MyTube\\Handling\\%s\\": "src/HandlingDomain/{*}/src/",
|
||||
"MyTube\\Infrastructure\\%s\\": "src/Infrastructure/{*}/src/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,13 +3,13 @@
|
||||
return [
|
||||
'api' => [
|
||||
'keys' => [
|
||||
'template' => $_ENV['HOMEPAGE_API_KEY'],
|
||||
'myTube' => $_ENV['HOMEPAGE_API_KEY'],
|
||||
'notification' => $_ENV['NOTIFICATION_API_KEY'],
|
||||
],
|
||||
|
||||
'services' => [
|
||||
'template' => [
|
||||
'host' => 'template-backend-nginx',
|
||||
'myTube' => [
|
||||
'host' => 'myTube-backend-nginx',
|
||||
'apis' => [
|
||||
|
||||
]
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'template-rbac' => [
|
||||
'myTube-rbac' => [
|
||||
'roles' => [
|
||||
'admin',
|
||||
'user',
|
||||
|
||||
@ -6,8 +6,8 @@ use Monolog\Level;
|
||||
|
||||
return [
|
||||
'logger' => [
|
||||
'name' => 'template.backend',
|
||||
'path' => APP_ROOT . '/var/log/template.backend.log',
|
||||
'name' => 'myTube.backend',
|
||||
'path' => APP_ROOT . '/var/log/myTube.backend.log',
|
||||
'level' => Level::Debug,
|
||||
'pretty' => true,
|
||||
]
|
||||
|
||||
@ -11,14 +11,14 @@ return [
|
||||
// `composer clear-config-cache`.
|
||||
ConfigAggregator::ENABLE_CACHE => false,
|
||||
|
||||
// Enable debugging; typically used to provide debugging information within templates.
|
||||
// Enable debugging; typically used to provide debugging information within myTubes.
|
||||
'debug' => false,
|
||||
'mezzio' => [
|
||||
// Provide templates for the error handling middleware to use when
|
||||
// Provide myTubes for the error handling middleware to use when
|
||||
// generating responses.
|
||||
'error_handler' => [
|
||||
'template_404' => 'error::404',
|
||||
'template_error' => 'error::error',
|
||||
'myTube_404' => 'error::404',
|
||||
'myTube_error' => 'error::error',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@ -40,34 +40,32 @@ $aggregator = new ConfigAggregator([
|
||||
|
||||
|
||||
// Data
|
||||
\Template\Data\Business\ConfigProvider::class,
|
||||
\Template\Data\Log\ConfigProvider::class,
|
||||
\MyTube\Data\Business\ConfigProvider::class,
|
||||
\MyTube\Data\Log\ConfigProvider::class,
|
||||
|
||||
// Infrastructure
|
||||
\Template\Infrastructure\Database\ConfigProvider::class,
|
||||
\Template\Infrastructure\DependencyInjection\ConfigProvider::class,
|
||||
\Template\Infrastructure\Encryption\ConfigProvider::class,
|
||||
\Template\Infrastructure\Exception\ConfigProvider::class,
|
||||
\Template\Infrastructure\Logging\ConfigProvider::class,
|
||||
\Template\Infrastructure\Rbac\ConfigProvider::class,
|
||||
\Template\Infrastructure\Request\ConfigProvider::class,
|
||||
\Template\Infrastructure\Session\ConfigProvider::class,
|
||||
\MyTube\Infrastructure\Database\ConfigProvider::class,
|
||||
\MyTube\Infrastructure\DependencyInjection\ConfigProvider::class,
|
||||
\MyTube\Infrastructure\Encryption\ConfigProvider::class,
|
||||
\MyTube\Infrastructure\Exception\ConfigProvider::class,
|
||||
\MyTube\Infrastructure\Logging\ConfigProvider::class,
|
||||
\MyTube\Infrastructure\Rbac\ConfigProvider::class,
|
||||
\MyTube\Infrastructure\Request\ConfigProvider::class,
|
||||
\MyTube\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,
|
||||
\MyTube\Handling\User\ConfigProvider::class,
|
||||
\MyTube\Handling\UserSession\ConfigProvider::class,
|
||||
\MyTube\Handling\Registration\ConfigProvider::class,
|
||||
|
||||
// API
|
||||
/// Command
|
||||
\Template\API\Console\ConfigProvider::class,
|
||||
\MyTube\API\Console\ConfigProvider::class,
|
||||
|
||||
/// 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,
|
||||
\MyTube\API\External\Health\ConfigProvider::class,
|
||||
\MyTube\API\External\User\ConfigProvider::class,
|
||||
\MyTube\API\External\Authentication\ConfigProvider::class,
|
||||
|
||||
/// Internal
|
||||
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Template\Infrastructure\Exception\Middleware\TemplateExceptionHandlerMiddleware;
|
||||
use Template\Infrastructure\Request\Middleware\AnalyzeHeaderMiddleware;
|
||||
use Template\Infrastructure\Session\Middleware\SessionMiddleware;
|
||||
use MyTube\Infrastructure\Exception\Middleware\MyTubeExceptionHandlerMiddleware;
|
||||
use MyTube\Infrastructure\Request\Middleware\AnalyzeHeaderMiddleware;
|
||||
use MyTube\Infrastructure\Session\Middleware\SessionMiddleware;
|
||||
use Laminas\Stratigility\Middleware\ErrorHandler;
|
||||
use Mezzio\Application;
|
||||
use Mezzio\Handler\NotFoundHandler;
|
||||
@ -66,11 +66,11 @@ return function (Application $app, MiddlewareFactory $factory, ContainerInterfac
|
||||
|
||||
|
||||
|
||||
//// Pre Template Space
|
||||
$app->pipe(TemplateExceptionHandlerMiddleware::class);
|
||||
//// Pre MyTube Space
|
||||
$app->pipe(MyTubeExceptionHandlerMiddleware::class);
|
||||
$app->pipe(AnalyzeHeaderMiddleware::class);
|
||||
|
||||
//// Template Space
|
||||
//// MyTube Space
|
||||
$app->pipe(SessionMiddleware::class);
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
use Mezzio\Application;
|
||||
use Mezzio\MiddlewareFactory;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Template\Infrastructure\Session\Middleware\LoggedInUserMiddleware;
|
||||
use MyTube\Infrastructure\Session\Middleware\LoggedInUserMiddleware;
|
||||
|
||||
/**
|
||||
* laminas-router route configuration
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\Migrations\Log;
|
||||
namespace MyTube\Migrations\Log;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\Migrations\Template;
|
||||
namespace MyTube\Migrations\MyTube;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\Migrations\Template;
|
||||
namespace MyTube\Migrations\MyTube;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\Migrations\Template;
|
||||
namespace MyTube\Migrations\MyTube;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\Migrations\Template;
|
||||
namespace MyTube\Migrations\MyTube;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\Migrations\Template;
|
||||
namespace MyTube\Migrations\MyTube;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\Migrations\Template;
|
||||
namespace MyTube\Migrations\MyTube;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
@ -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,18 +1,18 @@
|
||||
version: '3'
|
||||
networks:
|
||||
template:
|
||||
myTube:
|
||||
external: true
|
||||
|
||||
services:
|
||||
template-backend-mysql:
|
||||
image: template-backend-mysql
|
||||
myTube-backend-mysql:
|
||||
image: myTube-backend-mysql
|
||||
networks:
|
||||
- template
|
||||
- myTube
|
||||
build:
|
||||
context: ./../
|
||||
dockerfile: ./docker/mysql/dockerfile
|
||||
volumes:
|
||||
- /Users/flo/dev/backend/template/var/db:/var/lib/mysql:z
|
||||
- /Users/flo/dev/backend/myTube/var/db:/var/lib/mysql:z
|
||||
environment:
|
||||
MYSQL_USER: ${DB_USER}
|
||||
MYSQL_PASSWORD: ${DB_PASSWORD}
|
||||
@ -23,29 +23,29 @@ services:
|
||||
timeout: 20s
|
||||
retries: 10
|
||||
|
||||
template-backend-app:
|
||||
image: template-backend-app
|
||||
myTube-backend-app:
|
||||
image: myTube-backend-app
|
||||
networks:
|
||||
- template
|
||||
- myTube
|
||||
build:
|
||||
context: ./../
|
||||
dockerfile: ./docker/php/dockerfile
|
||||
volumes:
|
||||
- /Users/flo/dev/backend/template/:/var/www/html:z
|
||||
- /Users/flo/dev/backend/myTube/:/var/www/html:z
|
||||
ports:
|
||||
- 9000:9000
|
||||
depends_on:
|
||||
template-backend-mysql:
|
||||
myTube-backend-mysql:
|
||||
condition: service_healthy
|
||||
|
||||
template-backend-nginx:
|
||||
image: template-backend-nginx
|
||||
myTube-backend-nginx:
|
||||
image: myTube-backend-nginx
|
||||
networks:
|
||||
- template
|
||||
- myTube
|
||||
build:
|
||||
context: ./../
|
||||
dockerfile: ./docker/nginx/dockerfile
|
||||
ports:
|
||||
- 8080:80
|
||||
depends_on:
|
||||
- template-backend-app
|
||||
- myTube-backend-app
|
||||
@ -1,13 +1,13 @@
|
||||
version: '3'
|
||||
networks:
|
||||
template:
|
||||
mytube:
|
||||
external: true
|
||||
|
||||
services:
|
||||
template-backend-mysql:
|
||||
image: template-backend-mysql
|
||||
mytube-backend-mysql:
|
||||
image: mytube-backend-mysql
|
||||
networks:
|
||||
- template
|
||||
- mytube
|
||||
build:
|
||||
context: ./../
|
||||
dockerfile: ./docker/mysql/dockerfile
|
||||
@ -23,10 +23,10 @@ services:
|
||||
timeout: 20s
|
||||
retries: 10
|
||||
|
||||
template-backend-app:
|
||||
image: template-backend-app
|
||||
mytube-backend-app:
|
||||
image: mytube-backend-app
|
||||
networks:
|
||||
- template
|
||||
- mytube
|
||||
build:
|
||||
context: ./../
|
||||
dockerfile: ./docker/php/dockerfile
|
||||
@ -35,17 +35,17 @@ services:
|
||||
ports:
|
||||
- 9000:9000
|
||||
depends_on:
|
||||
template-backend-mysql:
|
||||
mytube-backend-mysql:
|
||||
condition: service_healthy
|
||||
|
||||
template-backend-nginx:
|
||||
image: template-backend-nginx
|
||||
mytube-backend-nginx:
|
||||
image: mytube-backend-nginx
|
||||
networks:
|
||||
- template
|
||||
- mytube
|
||||
build:
|
||||
context: ./../
|
||||
dockerfile: ./docker/nginx/dockerfile
|
||||
ports:
|
||||
- 8080:80
|
||||
depends_on:
|
||||
- template-backend-app
|
||||
- mytube-backend-app
|
||||
@ -1,4 +1,4 @@
|
||||
CREATE DATABASE IF NOT EXISTS `log`;
|
||||
CREATE DATABASE IF NOT EXISTS `template`;
|
||||
CREATE DATABASE IF NOT EXISTS `myTube`;
|
||||
|
||||
GRANT ALL PRIVILEGES on *.* to 'template'@'%';
|
||||
GRANT ALL PRIVILEGES on *.* to 'myTube'@'%';
|
||||
@ -1,5 +1,5 @@
|
||||
upstream host-backend-app {
|
||||
server template-backend-app:9000;
|
||||
server myTube-backend-app:9000;
|
||||
}
|
||||
|
||||
server {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Template\API\Console\Command\InitializeDataCommand;
|
||||
use Template\API\Console\Command\RbacUpdateCommand;
|
||||
use MyTube\API\Console\Command\InitializeDataCommand;
|
||||
use MyTube\API\Console\Command\RbacUpdateCommand;
|
||||
|
||||
return [
|
||||
'commands' => [
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Template\API\Console\Command\InitializeDataCommand;
|
||||
use Template\API\Console\Command\RbacUpdateCommand;
|
||||
use MyTube\API\Console\Command\InitializeDataCommand;
|
||||
use MyTube\API\Console\Command\RbacUpdateCommand;
|
||||
use Reinfi\DependencyInjection\Factory\AutoWiringFactory;
|
||||
|
||||
return [
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Template\API\Console\Command;
|
||||
namespace MyTube\API\Console\Command;
|
||||
|
||||
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\Infrastructure\Encryption\Client\EncryptionClient;
|
||||
use Template\Infrastructure\Logging\Logger\Logger;
|
||||
use MyTube\Data\Business\Entity\Role;
|
||||
use MyTube\Data\Business\Entity\User;
|
||||
use MyTube\Data\Business\Repository\RoleRepository;
|
||||
use MyTube\Data\Business\Repository\UserRepository;
|
||||
use MyTube\Data\Business\Manager\MyTubeEntityManager;
|
||||
use MyTube\Infrastructure\Encryption\Client\EncryptionClient;
|
||||
use MyTube\Infrastructure\Logging\Logger\Logger;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
@ -23,7 +23,7 @@ class InitializeDataCommand extends Command
|
||||
|
||||
public function __construct(
|
||||
private readonly EncryptionClient $encryptionClient,
|
||||
private readonly TemplateEntityManager $entityManager,
|
||||
private readonly MyTubeEntityManager $entityManager,
|
||||
private readonly Logger $logger,
|
||||
) {
|
||||
parent::__construct($this->getName());
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Template\API\Console\Command;
|
||||
namespace MyTube\API\Console\Command;
|
||||
|
||||
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\Infrastructure\Logging\Logger\Logger;
|
||||
use MyTube\Data\Business\Entity\Permission;
|
||||
use MyTube\Data\Business\Entity\Role;
|
||||
use MyTube\Data\Business\Repository\PermissionRepository;
|
||||
use MyTube\Data\Business\Repository\RoleRepository;
|
||||
use MyTube\Data\Business\Manager\MyTubeEntityManager;
|
||||
use MyTube\Infrastructure\Logging\Logger\Logger;
|
||||
use Reinfi\DependencyInjection\Service\ConfigService;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
@ -24,7 +24,7 @@ class RbacUpdateCommand extends Command
|
||||
|
||||
public function __construct(
|
||||
private readonly ConfigService $configService,
|
||||
private readonly TemplateEntityManager $entityManager,
|
||||
private readonly MyTubeEntityManager $entityManager,
|
||||
private readonly Logger $logger,
|
||||
) {
|
||||
parent::__construct($this->getName());
|
||||
@ -32,7 +32,7 @@ class RbacUpdateCommand extends Command
|
||||
$this->roleRepository = $this->entityManager->getRepository(Role::class);
|
||||
$this->permissionRepository = $this->entityManager->getRepository(Permission::class);
|
||||
|
||||
$this->rbacConfig = $this->configService->resolve('template-rbac')->toArray();
|
||||
$this->rbacConfig = $this->configService->resolve('myTube-rbac')->toArray();
|
||||
}
|
||||
|
||||
protected function execute(
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\API\Console;
|
||||
namespace MyTube\API\Console;
|
||||
|
||||
class ConfigProvider
|
||||
{
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
use Template\API\External\Authentication\Handler\ConfirmRegistrationHandler;
|
||||
use Template\API\External\Authentication\Handler\LoginUserHandler;
|
||||
use Template\API\External\Authentication\Handler\LogoutUserHandler;
|
||||
use Template\API\External\Authentication\Handler\RegisterUserHandler;
|
||||
use Template\Infrastructure\Session\Middleware\LoggedInUserMiddleware;
|
||||
use MyTube\API\External\Authentication\Handler\ConfirmRegistrationHandler;
|
||||
use MyTube\API\External\Authentication\Handler\LoginUserHandler;
|
||||
use MyTube\API\External\Authentication\Handler\LogoutUserHandler;
|
||||
use MyTube\API\External\Authentication\Handler\RegisterUserHandler;
|
||||
use MyTube\Infrastructure\Session\Middleware\LoggedInUserMiddleware;
|
||||
|
||||
return [
|
||||
[
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Template\API\External\Authentication\Handler\ConfirmRegistrationHandler;
|
||||
use Template\API\External\Authentication\Handler\LoginUserHandler;
|
||||
use Template\API\External\Authentication\Handler\LogoutUserHandler;
|
||||
use Template\API\External\Authentication\Handler\RegisterUserHandler;
|
||||
use MyTube\API\External\Authentication\Handler\ConfirmRegistrationHandler;
|
||||
use MyTube\API\External\Authentication\Handler\LoginUserHandler;
|
||||
use MyTube\API\External\Authentication\Handler\LogoutUserHandler;
|
||||
use MyTube\API\External\Authentication\Handler\RegisterUserHandler;
|
||||
use Reinfi\DependencyInjection\Factory\AutoWiringFactory;
|
||||
|
||||
return [
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\API\External\Authentication;
|
||||
namespace MyTube\API\External\Authentication;
|
||||
|
||||
class ConfigProvider
|
||||
{
|
||||
|
||||
@ -2,12 +2,12 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\API\External\Authentication\Handler;
|
||||
namespace MyTube\API\External\Authentication\Handler;
|
||||
|
||||
use Template\API\External\User\Formatter\UserFormatter;
|
||||
use Template\Handling\Registration\Handler\Command\ConfirmRegistration\ConfirmRegistrationCommandBuilder;
|
||||
use Template\Handling\Registration\Handler\Command\ConfirmRegistration\ConfirmRegistrationCommandHandler;
|
||||
use Template\Infrastructure\Session\Middleware\SessionMiddleware;
|
||||
use MyTube\API\External\User\Formatter\UserFormatter;
|
||||
use MyTube\Handling\Registration\Handler\Command\ConfirmRegistration\ConfirmRegistrationCommandBuilder;
|
||||
use MyTube\Handling\Registration\Handler\Command\ConfirmRegistration\ConfirmRegistrationCommandHandler;
|
||||
use MyTube\Infrastructure\Session\Middleware\SessionMiddleware;
|
||||
use Laminas\Diactoros\Response\JsonResponse;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
@ -2,11 +2,11 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\API\External\Authentication\Handler;
|
||||
namespace MyTube\API\External\Authentication\Handler;
|
||||
|
||||
use Template\Handling\UserSession\Handler\Command\LoginUser\LoginUserCommandBuilder;
|
||||
use Template\Handling\UserSession\Handler\Command\LoginUser\LoginUserCommandHandler;
|
||||
use Template\Infrastructure\Session\Middleware\SessionMiddleware;
|
||||
use MyTube\Handling\UserSession\Handler\Command\LoginUser\LoginUserCommandBuilder;
|
||||
use MyTube\Handling\UserSession\Handler\Command\LoginUser\LoginUserCommandHandler;
|
||||
use MyTube\Infrastructure\Session\Middleware\SessionMiddleware;
|
||||
use Laminas\Diactoros\Response\JsonResponse;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
@ -2,12 +2,12 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\API\External\Authentication\Handler;
|
||||
namespace MyTube\API\External\Authentication\Handler;
|
||||
|
||||
use Template\Handling\UserSession\Handler\Command\LogoutUser\LogoutUserCommandBuilder;
|
||||
use Template\Handling\UserSession\Handler\Command\LogoutUser\LogoutUserCommandHandler;
|
||||
use Template\Infrastructure\Response\SuccessResponse;
|
||||
use Template\Infrastructure\Session\Middleware\SessionMiddleware;
|
||||
use MyTube\Handling\UserSession\Handler\Command\LogoutUser\LogoutUserCommandBuilder;
|
||||
use MyTube\Handling\UserSession\Handler\Command\LogoutUser\LogoutUserCommandHandler;
|
||||
use MyTube\Infrastructure\Response\SuccessResponse;
|
||||
use MyTube\Infrastructure\Session\Middleware\SessionMiddleware;
|
||||
use Laminas\Diactoros\Response\JsonResponse;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
@ -2,15 +2,15 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\API\External\Authentication\Handler;
|
||||
namespace MyTube\API\External\Authentication\Handler;
|
||||
|
||||
use Template\Handling\Registration\Handler\Command\RegisterUser\RegisterUserCommandBuilder;
|
||||
use Template\Handling\Registration\Handler\Command\RegisterUser\RegisterUserCommandHandler;
|
||||
use Template\Infrastructure\Exception\Middleware\TemplateExceptionHandlerMiddleware;
|
||||
use Template\Infrastructure\Logging\Logger\Logger;
|
||||
use Template\Infrastructure\Request\Middleware\AnalyzeHeaderMiddleware;
|
||||
use Template\Infrastructure\Response\SuccessResponse;
|
||||
use Template\Infrastructure\Session\Middleware\SessionMiddleware;
|
||||
use MyTube\Handling\Registration\Handler\Command\RegisterUser\RegisterUserCommandBuilder;
|
||||
use MyTube\Handling\Registration\Handler\Command\RegisterUser\RegisterUserCommandHandler;
|
||||
use MyTube\Infrastructure\Exception\Middleware\MyTubeExceptionHandlerMiddleware;
|
||||
use MyTube\Infrastructure\Logging\Logger\Logger;
|
||||
use MyTube\Infrastructure\Request\Middleware\AnalyzeHeaderMiddleware;
|
||||
use MyTube\Infrastructure\Response\SuccessResponse;
|
||||
use MyTube\Infrastructure\Session\Middleware\SessionMiddleware;
|
||||
use Laminas\Diactoros\Response\JsonResponse;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Template\API\External\Health\Handler\HealthHandler;
|
||||
use MyTube\API\External\Health\Handler\HealthHandler;
|
||||
|
||||
return [
|
||||
[
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Template\API\External\Health\Handler\HealthHandler;
|
||||
use MyTube\API\External\Health\Handler\HealthHandler;
|
||||
use Reinfi\DependencyInjection\Factory\AutoWiringFactory;
|
||||
|
||||
return [
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\API\External\Health;
|
||||
namespace MyTube\API\External\Health;
|
||||
|
||||
class ConfigProvider
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\API\External\Health\Handler;
|
||||
namespace MyTube\API\External\Health\Handler;
|
||||
|
||||
use Laminas\Diactoros\Response\JsonResponse;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
12
src/ApiDomain/External/User/config/routes.php
vendored
12
src/ApiDomain/External/User/config/routes.php
vendored
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
use Template\API\External\User\Handler\ChangePasswordHandler;
|
||||
use Template\API\External\User\Handler\ChangeUsernameHandler;
|
||||
use Template\API\External\User\Handler\CreateUserHandler;
|
||||
use Template\API\External\User\Handler\UserStateHandler;
|
||||
use Template\Infrastructure\Rbac\Middleware\EnsureAuthorizationMiddleware;
|
||||
use Template\Infrastructure\Session\Middleware\LoggedInUserMiddleware;
|
||||
use MyTube\API\External\User\Handler\ChangePasswordHandler;
|
||||
use MyTube\API\External\User\Handler\ChangeUsernameHandler;
|
||||
use MyTube\API\External\User\Handler\CreateUserHandler;
|
||||
use MyTube\API\External\User\Handler\UserStateHandler;
|
||||
use MyTube\Infrastructure\Rbac\Middleware\EnsureAuthorizationMiddleware;
|
||||
use MyTube\Infrastructure\Session\Middleware\LoggedInUserMiddleware;
|
||||
|
||||
return [
|
||||
[
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
use Template\API\External\User\Formatter\UserFormatter;
|
||||
use Template\API\External\User\Handler\ChangePasswordHandler;
|
||||
use Template\API\External\User\Handler\ChangeUsernameHandler;
|
||||
use Template\API\External\User\Handler\CreateUserHandler;
|
||||
use Template\API\External\User\Handler\UserStateHandler;
|
||||
use MyTube\API\External\User\Formatter\UserFormatter;
|
||||
use MyTube\API\External\User\Handler\ChangePasswordHandler;
|
||||
use MyTube\API\External\User\Handler\ChangeUsernameHandler;
|
||||
use MyTube\API\External\User\Handler\CreateUserHandler;
|
||||
use MyTube\API\External\User\Handler\UserStateHandler;
|
||||
use Reinfi\DependencyInjection\Factory\AutoWiringFactory;
|
||||
|
||||
return [
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\API\External\User;
|
||||
namespace MyTube\API\External\User;
|
||||
|
||||
class ConfigProvider
|
||||
{
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Template\API\External\User\Formatter;
|
||||
namespace MyTube\API\External\User\Formatter;
|
||||
|
||||
use DateTime;
|
||||
use Template\Data\Business\Entity\User;
|
||||
use MyTube\Data\Business\Entity\User;
|
||||
|
||||
class UserFormatter {
|
||||
|
||||
|
||||
@ -2,13 +2,13 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\API\External\User\Handler;
|
||||
namespace MyTube\API\External\User\Handler;
|
||||
|
||||
use Template\Data\Business\Entity\User;
|
||||
use Template\Handling\User\Handler\Command\ChangePassword\ChangePasswordCommandBuilder;
|
||||
use Template\Handling\User\Handler\Command\ChangePassword\ChangePasswordCommandHandler;
|
||||
use Template\Infrastructure\Response\SuccessResponse;
|
||||
use Template\Infrastructure\Session\Middleware\LoggedInUserMiddleware;
|
||||
use MyTube\Data\Business\Entity\User;
|
||||
use MyTube\Handling\User\Handler\Command\ChangePassword\ChangePasswordCommandBuilder;
|
||||
use MyTube\Handling\User\Handler\Command\ChangePassword\ChangePasswordCommandHandler;
|
||||
use MyTube\Infrastructure\Response\SuccessResponse;
|
||||
use MyTube\Infrastructure\Session\Middleware\LoggedInUserMiddleware;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
@ -2,13 +2,13 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\API\External\User\Handler;
|
||||
namespace MyTube\API\External\User\Handler;
|
||||
|
||||
use Template\Data\Business\Entity\User;
|
||||
use Template\Handling\User\Handler\Command\ChangeUsername\ChangeUsernameCommandBuilder;
|
||||
use Template\Handling\User\Handler\Command\ChangeUsername\ChangeUsernameCommandHandler;
|
||||
use Template\Infrastructure\Response\SuccessResponse;
|
||||
use Template\Infrastructure\Session\Middleware\LoggedInUserMiddleware;
|
||||
use MyTube\Data\Business\Entity\User;
|
||||
use MyTube\Handling\User\Handler\Command\ChangeUsername\ChangeUsernameCommandBuilder;
|
||||
use MyTube\Handling\User\Handler\Command\ChangeUsername\ChangeUsernameCommandHandler;
|
||||
use MyTube\Infrastructure\Response\SuccessResponse;
|
||||
use MyTube\Infrastructure\Session\Middleware\LoggedInUserMiddleware;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
@ -2,11 +2,11 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\API\External\User\Handler;
|
||||
namespace MyTube\API\External\User\Handler;
|
||||
|
||||
use Template\API\External\User\Formatter\UserFormatter;
|
||||
use Template\Handling\User\Handler\Command\CreateUser\CreateUserCommandBuilder;
|
||||
use Template\Handling\User\Handler\Command\CreateUser\CreateUserCommandHandler;
|
||||
use MyTube\API\External\User\Formatter\UserFormatter;
|
||||
use MyTube\Handling\User\Handler\Command\CreateUser\CreateUserCommandBuilder;
|
||||
use MyTube\Handling\User\Handler\Command\CreateUser\CreateUserCommandHandler;
|
||||
use Laminas\Diactoros\Response\JsonResponse;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
@ -2,13 +2,13 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\API\External\User\Handler;
|
||||
namespace MyTube\API\External\User\Handler;
|
||||
|
||||
use Template\API\External\User\Formatter\UserFormatter;
|
||||
use Template\Data\Business\Entity\User;
|
||||
use Template\Handling\User\Handler\Command\CreateUser\CreateUserCommandBuilder;
|
||||
use Template\Handling\User\Handler\Command\CreateUser\ChangePasswordCommandHandler;
|
||||
use Template\Infrastructure\Session\Middleware\LoggedInUserMiddleware;
|
||||
use MyTube\API\External\User\Formatter\UserFormatter;
|
||||
use MyTube\Data\Business\Entity\User;
|
||||
use MyTube\Handling\User\Handler\Command\CreateUser\CreateUserCommandBuilder;
|
||||
use MyTube\Handling\User\Handler\Command\CreateUser\ChangePasswordCommandHandler;
|
||||
use MyTube\Infrastructure\Session\Middleware\LoggedInUserMiddleware;
|
||||
use Laminas\Diactoros\Response\JsonResponse;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
@ -6,7 +6,7 @@ use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
|
||||
|
||||
return [
|
||||
'configuration' => [
|
||||
'orm_template' => [
|
||||
'orm_myTube' => [
|
||||
'second_level_cache' => [
|
||||
'enabled' => false,
|
||||
]
|
||||
@ -14,7 +14,7 @@ return [
|
||||
],
|
||||
|
||||
'driver' => [
|
||||
'orm_template_annotation_driver' => [
|
||||
'orm_myTube_annotation_driver' => [
|
||||
'class' => AnnotationDriver::class,
|
||||
'cache' => 'array',
|
||||
'paths' => [
|
||||
@ -22,16 +22,16 @@ return [
|
||||
],
|
||||
],
|
||||
|
||||
'orm_template' => [
|
||||
'orm_myTube' => [
|
||||
'class' => MappingDriverChain::class,
|
||||
'drivers' => [
|
||||
'Template\Data\Business\Entity' => 'orm_template_annotation_driver',
|
||||
'MyTube\Data\Business\Entity' => 'orm_myTube_annotation_driver',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'connection' => [
|
||||
'orm_template' => [
|
||||
'orm_myTube' => [
|
||||
'driverClass' => Driver::class,
|
||||
'params' => [
|
||||
'driver' => $_ENV['DB_DRIVER'],
|
||||
@ -45,10 +45,10 @@ return [
|
||||
],
|
||||
|
||||
'migrations_configuration' => [
|
||||
'orm_template' => [
|
||||
'directory' => 'data/migrations/template',
|
||||
'name' => 'Doctrine Database Migrations for Template',
|
||||
'namespace' => 'Template\Migrations\Template',
|
||||
'orm_myTube' => [
|
||||
'directory' => 'data/migrations/myTube',
|
||||
'name' => 'Doctrine Database Migrations for MyTube',
|
||||
'namespace' => 'MyTube\Migrations\MyTube',
|
||||
'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\Repository\UserRepository;
|
||||
use Template\Infrastructure\Database\AutowireRepositoryFactory;
|
||||
use MyTube\Data\Business\Entity\User;
|
||||
use MyTube\Data\Business\Factory\MyTubeEntityManagerFactory;
|
||||
use MyTube\Data\Business\Manager\MyTubeEntityManager;
|
||||
use MyTube\Data\Business\Repository\UserRepository;
|
||||
use MyTube\Infrastructure\Database\AutowireRepositoryFactory;
|
||||
use Roave\PsrContainerDoctrine\ConfigurationFactory;
|
||||
use Roave\PsrContainerDoctrine\ConnectionFactory;
|
||||
use Roave\PsrContainerDoctrine\EntityManagerFactory;
|
||||
|
||||
return [
|
||||
'factories' => [
|
||||
'doctrine.entity_manager.orm_template' => [EntityManagerFactory::class, 'orm_template'],
|
||||
'doctrine.configuration.orm_template' => [ConfigurationFactory::class, 'orm_template'],
|
||||
'doctrine.connection.orm_template' => [ConnectionFactory::class, 'orm_template'],
|
||||
TemplateEntityManager::class => TemplateEntityManagerFactory::class,
|
||||
'doctrine.entity_manager.orm_myTube' => [EntityManagerFactory::class, 'orm_myTube'],
|
||||
'doctrine.configuration.orm_myTube' => [ConfigurationFactory::class, 'orm_myTube'],
|
||||
'doctrine.connection.orm_myTube' => [ConnectionFactory::class, 'orm_myTube'],
|
||||
MyTubeEntityManager::class => MyTubeEntityManagerFactory::class,
|
||||
|
||||
UserRepository::class => [AutowireRepositoryFactory::class, TemplateEntityManager::class, User::class],
|
||||
UserRepository::class => [AutowireRepositoryFactory::class, MyTubeEntityManager::class, User::class],
|
||||
],
|
||||
];
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\Data\Business;
|
||||
namespace MyTube\Data\Business;
|
||||
|
||||
class ConfigProvider
|
||||
{
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Data\Business\Entity;
|
||||
namespace MyTube\Data\Business\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Template\Infrastructure\UuidGenerator\UuidGenerator;
|
||||
use MyTube\Infrastructure\UuidGenerator\UuidGenerator;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="Template\Data\Business\Repository\PermissionRepository")
|
||||
* @ORM\Entity(repositoryClass="MyTube\Data\Business\Repository\PermissionRepository")
|
||||
* @ORM\Table(name="permission")
|
||||
*/
|
||||
class Permission {
|
||||
@ -23,7 +23,7 @@ class Permission {
|
||||
private ?UuidInterface $productId;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="Template\Data\Business\Entity\Product")
|
||||
* @ORM\OneToOne(targetEntity="MyTube\Data\Business\Entity\Product")
|
||||
* @ORM\JoinColumn(name="product_id", referencedColumnName="id", nullable=true)
|
||||
*/
|
||||
private ?Product $product;
|
||||
@ -32,7 +32,7 @@ class Permission {
|
||||
private string $identifier;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Template\Data\Business\Entity\Role", inversedBy="permissions")
|
||||
* @ORM\ManyToMany(targetEntity="MyTube\Data\Business\Entity\Role", inversedBy="permissions")
|
||||
* @ORM\JoinTable(
|
||||
* name="role_permission",
|
||||
* joinColumns={@ORM\JoinColumn(name="permission_id", referencedColumnName="id")},
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Data\Business\Entity;
|
||||
namespace MyTube\Data\Business\Entity;
|
||||
|
||||
use DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Template\Infrastructure\UuidGenerator\UuidGenerator;
|
||||
use MyTube\Infrastructure\UuidGenerator\UuidGenerator;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="Template\Data\Business\Repository\RegistrationRepository")
|
||||
* @ORM\Entity(repositoryClass="MyTube\Data\Business\Repository\RegistrationRepository")
|
||||
* @ORM\Table(name="registration")
|
||||
*/
|
||||
class Registration {
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Data\Business\Entity;
|
||||
namespace MyTube\Data\Business\Entity;
|
||||
|
||||
use DateTime;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Template\Infrastructure\UuidGenerator\UuidGenerator;
|
||||
use MyTube\Infrastructure\UuidGenerator\UuidGenerator;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="Template\Data\Business\Repository\RoleRepository")
|
||||
* @ORM\Entity(repositoryClass="MyTube\Data\Business\Repository\RoleRepository")
|
||||
* @ORM\Table(name="role")
|
||||
*/
|
||||
class Role {
|
||||
@ -24,7 +24,7 @@ class Role {
|
||||
private ?UuidInterface $productId;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="Template\Data\Business\Entity\Product")
|
||||
* @ORM\OneToOne(targetEntity="MyTube\Data\Business\Entity\Product")
|
||||
* @ORM\JoinColumn(name="product_id", referencedColumnName="id", nullable=true)
|
||||
*/
|
||||
private ?Product $product;
|
||||
@ -33,7 +33,7 @@ class Role {
|
||||
private string $identifier;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Template\Data\Business\Entity\Permission", mappedBy="roles")
|
||||
* @ORM\ManyToMany(targetEntity="MyTube\Data\Business\Entity\Permission", mappedBy="roles")
|
||||
* @ORM\JoinTable(
|
||||
* name="role_permission",
|
||||
* joinColumns={@ORM\JoinColumn(name="role_id", referencedColumnName="id")},
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Data\Business\Entity;
|
||||
namespace MyTube\Data\Business\Entity;
|
||||
|
||||
use DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Template\Infrastructure\UuidGenerator\UuidGenerator;
|
||||
use MyTube\Infrastructure\UuidGenerator\UuidGenerator;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="Template\Data\Business\Repository\UserRepository")
|
||||
* @ORM\Entity(repositoryClass="MyTube\Data\Business\Repository\UserRepository")
|
||||
* @ORM\Table(name="user")
|
||||
*/
|
||||
class User {
|
||||
@ -22,7 +22,7 @@ class User {
|
||||
private UuidInterface $roleId;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="Template\Data\Business\Entity\Role")
|
||||
* @ORM\OneToOne(targetEntity="MyTube\Data\Business\Entity\Role")
|
||||
* @ORM\JoinColumn(name="role_id", referencedColumnName="id")
|
||||
*/
|
||||
private Role $role;
|
||||
@ -36,7 +36,7 @@ class User {
|
||||
/** @ORM\Column(name="password", type="string") */
|
||||
private string $password;
|
||||
|
||||
/** @ORM\OneToOne(targetEntity="Template\Data\Business\Entity\UserSession", mappedBy="user") */
|
||||
/** @ORM\OneToOne(targetEntity="MyTube\Data\Business\Entity\UserSession", mappedBy="user") */
|
||||
private ?UserSession $session;
|
||||
|
||||
/** @ORM\Column(name="last_login_at", type="datetime", nullable=true) */
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Data\Business\Entity;
|
||||
namespace MyTube\Data\Business\Entity;
|
||||
|
||||
use DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Template\Infrastructure\UuidGenerator\UuidGenerator;
|
||||
use MyTube\Infrastructure\UuidGenerator\UuidGenerator;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="Template\Data\Business\Repository\UserSessionRepository")
|
||||
* @ORM\Entity(repositoryClass="MyTube\Data\Business\Repository\UserSessionRepository")
|
||||
* @ORM\Table(name="user_session")
|
||||
*/
|
||||
class UserSession {
|
||||
@ -22,7 +22,7 @@ class UserSession {
|
||||
private ?UuidInterface $userId;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="Template\Data\Business\Entity\User", mappedBy="session")
|
||||
* @ORM\OneToOne(targetEntity="MyTube\Data\Business\Entity\User", mappedBy="session")
|
||||
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=true)
|
||||
*/
|
||||
private ?User $user;
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MyTube\Data\Business\Factory;
|
||||
|
||||
use MyTube\Data\Business\Manager\MyTubeEntityManager;
|
||||
use Laminas\ServiceManager\Factory\FactoryInterface;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class MyTubeEntityManagerFactory implements FactoryInterface
|
||||
{
|
||||
public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): MyTubeEntityManager
|
||||
{
|
||||
return new MyTubeEntityManager(
|
||||
$container->get('doctrine.entity_manager.orm_myTube')
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\Data\Business\Factory;
|
||||
|
||||
use Template\Data\Business\Manager\TemplateEntityManager;
|
||||
use Laminas\ServiceManager\Factory\FactoryInterface;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class TemplateEntityManagerFactory implements FactoryInterface
|
||||
{
|
||||
public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): TemplateEntityManager
|
||||
{
|
||||
return new TemplateEntityManager(
|
||||
$container->get('doctrine.entity_manager.orm_template')
|
||||
);
|
||||
}
|
||||
}
|
||||
11
src/DataDomain/Business/src/Manager/MyTubeEntityManager.php
Normal file
11
src/DataDomain/Business/src/Manager/MyTubeEntityManager.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MyTube\Data\Business\Manager;
|
||||
|
||||
use Doctrine\ORM\Decorator\EntityManagerDecorator;
|
||||
|
||||
class MyTubeEntityManager extends EntityManagerDecorator
|
||||
{
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\Data\Business\Manager;
|
||||
|
||||
use Doctrine\ORM\Decorator\EntityManagerDecorator;
|
||||
|
||||
class TemplateEntityManager extends EntityManagerDecorator
|
||||
{
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Data\Business\Repository;
|
||||
namespace MyTube\Data\Business\Repository;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Data\Business\Repository;
|
||||
namespace MyTube\Data\Business\Repository;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Data\Business\Repository;
|
||||
namespace MyTube\Data\Business\Repository;
|
||||
|
||||
use Template\Data\Business\Entity\Registration;
|
||||
use MyTube\Data\Business\Entity\Registration;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
class RegistrationRepository extends EntityRepository {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Data\Business\Repository;
|
||||
namespace MyTube\Data\Business\Repository;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Data\Business\Repository;
|
||||
namespace MyTube\Data\Business\Repository;
|
||||
|
||||
use Template\Data\Business\Entity\User;
|
||||
use MyTube\Data\Business\Entity\User;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
class UserRepository extends EntityRepository {
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Data\Business\Repository;
|
||||
namespace MyTube\Data\Business\Repository;
|
||||
|
||||
use Template\Data\Business\Entity\User;
|
||||
use MyTube\Data\Business\Entity\User;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Template\Data\Business\Entity\UserSession;
|
||||
use MyTube\Data\Business\Entity\UserSession;
|
||||
|
||||
class UserSessionRepository extends EntityRepository {
|
||||
public function findByUser(User $user) : ?UserSession {
|
||||
|
||||
@ -25,7 +25,7 @@ return [
|
||||
'orm_log' => [
|
||||
'class' => MappingDriverChain::class,
|
||||
'drivers' => [
|
||||
'Template\Data\Log\Entity' => 'orm_log_annotation_driver',
|
||||
'MyTube\Data\Log\Entity' => 'orm_log_annotation_driver',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -48,7 +48,7 @@ return [
|
||||
'orm_log' => [
|
||||
'directory' => 'data/migrations/log',
|
||||
'name' => 'Doctrine Database Migrations for Log',
|
||||
'namespace' => 'Template\Migrations\Log',
|
||||
'namespace' => 'MyTube\Migrations\Log',
|
||||
'table' => 'migrations',
|
||||
],
|
||||
],
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Template\Data\Log\Factory\LogEntityManagerFactory;
|
||||
use Template\Data\Log\Manager\LogEntityManager;
|
||||
use MyTube\Data\Log\Factory\LogEntityManagerFactory;
|
||||
use MyTube\Data\Log\Manager\LogEntityManager;
|
||||
use Roave\PsrContainerDoctrine\ConfigurationFactory;
|
||||
use Roave\PsrContainerDoctrine\ConnectionFactory;
|
||||
use Roave\PsrContainerDoctrine\EntityManagerFactory;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\Data\Log;
|
||||
namespace MyTube\Data\Log;
|
||||
|
||||
class ConfigProvider
|
||||
{
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Data\Log\Entity;
|
||||
namespace MyTube\Data\Log\Entity;
|
||||
|
||||
use DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Template\Infrastructure\UuidGenerator\UuidGenerator;
|
||||
use MyTube\Infrastructure\UuidGenerator\UuidGenerator;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* Member
|
||||
* @ORM\Entity(repositoryClass="Template\Data\Log\Repository\LogRepository")
|
||||
* @ORM\Entity(repositoryClass="MyTube\Data\Log\Repository\LogRepository")
|
||||
* @ORM\Table(name="log")
|
||||
*/
|
||||
class Log
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\Data\Log\Factory;
|
||||
namespace MyTube\Data\Log\Factory;
|
||||
|
||||
use Template\Data\Log\Manager\LogEntityManager;
|
||||
use MyTube\Data\Log\Manager\LogEntityManager;
|
||||
use Laminas\ServiceManager\Factory\FactoryInterface;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\Data\Log\Manager;
|
||||
namespace MyTube\Data\Log\Manager;
|
||||
|
||||
use Doctrine\ORM\Decorator\EntityManagerDecorator;
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Data\Log\Repository;
|
||||
namespace MyTube\Data\Log\Repository;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,20 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Template\Handling\Registration\Builder\RegistrationBuilder;
|
||||
use Template\Handling\Registration\Handler\Command\ConfirmRegistration\ConfirmRegistrationCommandBuilder;
|
||||
use Template\Handling\Registration\Handler\Command\ConfirmRegistration\ConfirmRegistrationCommandHandler;
|
||||
use Template\Handling\Registration\Handler\Command\RegisterUser\RegisterUserCommandBuilder;
|
||||
use Template\Handling\Registration\Handler\Command\RegisterUser\RegisterUserCommandHandler;
|
||||
use Template\Handling\Registration\Pipeline\ConfirmRegistration\ConfirmRegistrationPipeline;
|
||||
use Template\Handling\Registration\Pipeline\ConfirmRegistration\Step\CreateUserStep;
|
||||
use Template\Handling\Registration\Pipeline\ConfirmRegistration\Step\LoadRegistrationStep;
|
||||
use Template\Handling\Registration\Pipeline\ConfirmRegistration\Step\SaveRegistrationAndUserStep;
|
||||
use Template\Handling\Registration\Pipeline\RegisterUser\RegisterUserPipeline;
|
||||
use Template\Handling\Registration\Pipeline\RegisterUser\Step\BuildRegistrationStep;
|
||||
use Template\Handling\Registration\Pipeline\RegisterUser\Step\CheckIdentifierStep;
|
||||
use Template\Handling\Registration\Pipeline\RegisterUser\Step\SaveRegistrationStep;
|
||||
use Template\Handling\Registration\Pipeline\RegisterUser\Step\SendMailStep;
|
||||
use Template\Handling\Registration\Rule\RegistrationWithIdentifierAlreadyExistsRule;
|
||||
use MyTube\Handling\Registration\Builder\RegistrationBuilder;
|
||||
use MyTube\Handling\Registration\Handler\Command\ConfirmRegistration\ConfirmRegistrationCommandBuilder;
|
||||
use MyTube\Handling\Registration\Handler\Command\ConfirmRegistration\ConfirmRegistrationCommandHandler;
|
||||
use MyTube\Handling\Registration\Handler\Command\RegisterUser\RegisterUserCommandBuilder;
|
||||
use MyTube\Handling\Registration\Handler\Command\RegisterUser\RegisterUserCommandHandler;
|
||||
use MyTube\Handling\Registration\Pipeline\ConfirmRegistration\ConfirmRegistrationPipeline;
|
||||
use MyTube\Handling\Registration\Pipeline\ConfirmRegistration\Step\CreateUserStep;
|
||||
use MyTube\Handling\Registration\Pipeline\ConfirmRegistration\Step\LoadRegistrationStep;
|
||||
use MyTube\Handling\Registration\Pipeline\ConfirmRegistration\Step\SaveRegistrationAndUserStep;
|
||||
use MyTube\Handling\Registration\Pipeline\RegisterUser\RegisterUserPipeline;
|
||||
use MyTube\Handling\Registration\Pipeline\RegisterUser\Step\BuildRegistrationStep;
|
||||
use MyTube\Handling\Registration\Pipeline\RegisterUser\Step\CheckIdentifierStep;
|
||||
use MyTube\Handling\Registration\Pipeline\RegisterUser\Step\SaveRegistrationStep;
|
||||
use MyTube\Handling\Registration\Pipeline\RegisterUser\Step\SendMailStep;
|
||||
use MyTube\Handling\Registration\Rule\RegistrationWithIdentifierAlreadyExistsRule;
|
||||
use Reinfi\DependencyInjection\Factory\AutoWiringFactory;
|
||||
use Reinfi\DependencyInjection\Factory\InjectionFactory;
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Handling\Registration\Builder;
|
||||
namespace MyTube\Handling\Registration\Builder;
|
||||
|
||||
use Template\Data\Business\Entity\Registration;
|
||||
use MyTube\Data\Business\Entity\Registration;
|
||||
|
||||
class RegistrationBuilder
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Template\Handling\Registration;
|
||||
namespace MyTube\Handling\Registration;
|
||||
|
||||
class ConfigProvider
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user