intermediate commit
This commit is contained in:
parent
7ac14134df
commit
edf1817bac
40
.github/workflows/create branch on issue.yml
vendored
40
.github/workflows/create branch on issue.yml
vendored
@ -1,40 +0,0 @@
|
||||
name: Create Branch on Issue Transition to In Progress
|
||||
|
||||
on:
|
||||
issues:
|
||||
types:
|
||||
- edited
|
||||
|
||||
jobs:
|
||||
create-branch:
|
||||
if: github.event.changes.issue.labels
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Get issue details
|
||||
run: |
|
||||
issue_title=$(jq -r ".issue.number" "$GITHUB_EVENT_PATH")
|
||||
previous_labels=$(jq -r ".changes.labels.from" "$GITHUB_EVENT_PATH")
|
||||
current_labels=$(jq -r ".issue.labels | map(.name) | join(\", \")" "$GITHUB_EVENT_PATH")
|
||||
branch_name=""
|
||||
|
||||
# Check if the issue transitioned from 'Todo' to 'In Progress'
|
||||
if [[ "$previous_labels" == *"Todo"* && "$current_labels" == *"In Progress"* ]]; then
|
||||
project_name="hp-be" # Verwende "hp-be" als Projektnamen
|
||||
branch_name="${project_name}-${issue_title}"
|
||||
echo "Branch name: $branch_name"
|
||||
fi
|
||||
|
||||
echo "::set-output name=branch_name::$branch_name"
|
||||
shell: bash
|
||||
|
||||
- name: Create and switch to new branch
|
||||
run: |
|
||||
branch_name="${{ steps.create-branch.outputs.branch_name }}"
|
||||
if [ -n "$branch_name" ]; then
|
||||
git checkout -b "$branch_name"
|
||||
git push origin "$branch_name"
|
||||
fi
|
||||
working-directory: ${{ github.workspace }}
|
||||
39
.github/workflows/php.yml
vendored
39
.github/workflows/php.yml
vendored
@ -1,39 +0,0 @@
|
||||
name: PHP Composer
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Validate composer.json and composer.lock
|
||||
run: composer validate --strict
|
||||
|
||||
- name: Cache Composer packages
|
||||
id: composer-cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: vendor
|
||||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-php-
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --prefer-dist --no-progress
|
||||
|
||||
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
|
||||
# Docs: https://getcomposer.org/doc/articles/scripts.md
|
||||
|
||||
# - name: Run test suite
|
||||
# run: composer run-script test
|
||||
@ -109,12 +109,11 @@ return [
|
||||
'factories' => [
|
||||
// Handler
|
||||
{$apiHandlerName}::class => AutoWiringFactory::class,
|
||||
|
||||
|
||||
// Response Formatter
|
||||
{$apiResponseFormatterName}::class => AutoWiringFactory::class,
|
||||
],
|
||||
];
|
||||
|
||||
";
|
||||
writeToFile($serviceManagerFilePath, $serviceManagerFileContent);
|
||||
|
||||
@ -129,7 +128,7 @@ use {$apiHandlerUsingNamespace};
|
||||
return [
|
||||
[
|
||||
'name' => '{$routeName}',
|
||||
'path' => '/api/{$routePath}[/]',
|
||||
'path' => '/api/{$routePath}/',
|
||||
'allowed_methods' => ['POST'],
|
||||
'middleware' => [
|
||||
{$apiHandlerName}::class,
|
||||
@ -179,7 +178,6 @@ return [
|
||||
{$cqrsHandlerName}::class => AutoWiringFactory::class,
|
||||
],
|
||||
];
|
||||
|
||||
";
|
||||
writeToFile($serviceManagerFilePath, $serviceManagerFileContent);
|
||||
}
|
||||
@ -192,12 +190,13 @@ declare(strict_types=1);
|
||||
namespace {$apiHandlerNamespace};
|
||||
|
||||
use {$apiResponseFormatterUsingNamespace};
|
||||
use {$cqrsHandlerUsingNamespace};
|
||||
use {$cqrsBuilderUsingNamespace};
|
||||
use {$cqrsHandlerUsingNamespace};
|
||||
use {$projectNamespace}\\Infrastructure\\Request\\Middleware\\AnalyzeBodyMiddleware;
|
||||
use {$projectNamespace}\\Infrastructure\\Response\\SuccessResponse;
|
||||
use Psr\\Http\\Message\\ResponseInterface;
|
||||
use Psr\\Http\\Message\\ServerRequestInterface;
|
||||
use Psr\\Http\\Server\\RequestHandlerInterface;
|
||||
use {$projectNamespace}\\Infrastructure\\Response\\SuccessResponse;
|
||||
|
||||
class {$apiHandlerName} implements RequestHandlerInterface
|
||||
{
|
||||
@ -207,13 +206,10 @@ class {$apiHandlerName} implements RequestHandlerInterface
|
||||
private readonly {$apiResponseFormatterName} \$responseFormatter,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
public function handle(ServerRequestInterface \$request): ResponseInterface
|
||||
{
|
||||
\$data = json_decode(
|
||||
\$request->getBody()->getContents(),
|
||||
true
|
||||
);
|
||||
\$data = \$request->getAttribute(AnalyzeBodyMiddleware::JSON_DATA);
|
||||
|
||||
\${$cqrsVariableName} = \$this->{$cqrsBuilderVariableName}->build(
|
||||
\$data
|
||||
|
||||
@ -88,7 +88,7 @@ class {$stepClassName} implements TaskInterface
|
||||
#TODO
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
public function __invoke(
|
||||
\$payload,
|
||||
PipelineInterface \$pipeline
|
||||
@ -96,7 +96,9 @@ class {$stepClassName} implements TaskInterface
|
||||
{
|
||||
/** @var {$payloadClassName} \${$payloadVariableName} */
|
||||
\${$payloadVariableName} = \$payload;
|
||||
|
||||
|
||||
|
||||
\$pipeline->next()(\$payload, \$pipeline);
|
||||
}
|
||||
}
|
||||
@ -122,7 +124,7 @@ use teewurst\\Pipeline\\Pipeline;
|
||||
class {$pipelineClassName} extends Pipeline
|
||||
{
|
||||
public function __construct(
|
||||
{$stepsDeclaration}
|
||||
{$stepsDeclaration}
|
||||
) {
|
||||
parent::__construct([
|
||||
{$stepsReference}
|
||||
@ -142,7 +144,7 @@ class {$payloadClassName}
|
||||
{
|
||||
public function __construct(
|
||||
#TODO
|
||||
) {
|
||||
) {
|
||||
}
|
||||
}
|
||||
";
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
use Template\Infrastructure\Exception\Middleware\TemplateExceptionHandlerMiddleware;
|
||||
use Template\Infrastructure\Request\Middleware\AnalyzeBodyMiddleware;
|
||||
use Template\Infrastructure\Request\Middleware\AnalyzeHeaderMiddleware;
|
||||
use Template\Infrastructure\Session\Middleware\SessionMiddleware;
|
||||
use Laminas\Stratigility\Middleware\ErrorHandler;
|
||||
@ -69,6 +70,7 @@ return function (Application $app, MiddlewareFactory $factory, ContainerInterfac
|
||||
//// Pre Template Space
|
||||
$app->pipe(TemplateExceptionHandlerMiddleware::class);
|
||||
$app->pipe(AnalyzeHeaderMiddleware::class);
|
||||
$app->pipe(AnalyzeBodyMiddleware::class);
|
||||
|
||||
//// Template Space
|
||||
$app->pipe(SessionMiddleware::class);
|
||||
|
||||
@ -2,13 +2,12 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Template\Infrastructure\Rbac\Middleware\EnsureAuthorizationMiddleware;
|
||||
use Reinfi\DependencyInjection\Factory\AutoWiringFactory;
|
||||
use Template\Infrastructure\Request\Factory\RequestServiceFactory;
|
||||
use Template\Infrastructure\Request\Middleware\AnalyzeBodyMiddleware;
|
||||
use Template\Infrastructure\Request\Middleware\AnalyzeHeaderMiddleware;
|
||||
use Template\Infrastructure\Request\Middleware\InternalRequestMiddleware;
|
||||
use Template\Infrastructure\Request\Service\RequestService;
|
||||
use Reinfi\DependencyInjection\Factory\AutoWiringFactory;
|
||||
use Reinfi\DependencyInjection\Factory\InjectionFactory;
|
||||
|
||||
return [
|
||||
'factories' => [
|
||||
@ -17,6 +16,7 @@ return [
|
||||
|
||||
/// Middleware
|
||||
AnalyzeHeaderMiddleware::class => AutoWiringFactory::class,
|
||||
AnalyzeBodyMiddleware::class => AutoWiringFactory::class,
|
||||
InternalRequestMiddleware::class => AutoWiringFactory::class,
|
||||
],
|
||||
];
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Template\Infrastructure\Request\Middleware;
|
||||
|
||||
use Template\Data\Business\Entity\Permission;
|
||||
use Template\Data\Business\Entity\User;
|
||||
use Template\Infrastructure\Response\ForbiddenResponse;
|
||||
use Template\Infrastructure\Session\Middleware\LoggedInUserMiddleware;
|
||||
use Laminas\Config\Config;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Reinfi\DependencyInjection\Annotation\InjectConfig;
|
||||
|
||||
class AnalyzeBodyMiddleware implements MiddlewareInterface
|
||||
{
|
||||
const JSON_DATA = 'json_data_attribute';
|
||||
|
||||
private const CONTENT_TYPE_HEADER = 'Content-Type';
|
||||
private const CONTENT_TYPE_APPLICATION_JSON = 'application/json';
|
||||
|
||||
public function process(
|
||||
ServerRequestInterface $request,
|
||||
RequestHandlerInterface $handler
|
||||
): ResponseInterface
|
||||
{
|
||||
$jsonData = [];
|
||||
$contentType = $request->getHeaderLine(self::CONTENT_TYPE_HEADER);
|
||||
|
||||
if (str_contains($contentType, self::CONTENT_TYPE_APPLICATION_JSON)) {
|
||||
$jsonData = json_decode(
|
||||
$request->getBody()->getContents(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
return $handler->handle($request->withAttribute(
|
||||
self::JSON_DATA,
|
||||
$jsonData
|
||||
));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user