Basket Bundle Attributes

This commit is contained in:
Thomas Peterson 2025-12-13 18:24:33 +01:00
parent e044a424fa
commit c504f9e4de
7 changed files with 124 additions and 113 deletions

View File

@ -474,7 +474,7 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
* datetime?: array{ * datetime?: array{
* default_format?: scalar|null, // Default: "Y-m-d\\TH:i:sP" * default_format?: scalar|null, // Default: "Y-m-d\\TH:i:sP"
* default_deserialization_formats?: list<scalar|null>, * default_deserialization_formats?: list<scalar|null>,
* default_timezone?: scalar|null, // Default: "UTC" * default_timezone?: scalar|null, // Default: "Europe/Berlin"
* cdata?: scalar|null, // Default: true * cdata?: scalar|null, // Default: true
* }, * },
* array_collection?: array{ * array_collection?: array{
@ -574,7 +574,7 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
* datetime?: array{ * datetime?: array{
* default_format?: scalar|null, // Default: "Y-m-d\\TH:i:sP" * default_format?: scalar|null, // Default: "Y-m-d\\TH:i:sP"
* default_deserialization_formats?: list<scalar|null>, * default_deserialization_formats?: list<scalar|null>,
* default_timezone?: scalar|null, // Default: "UTC" * default_timezone?: scalar|null, // Default: "Europe/Berlin"
* cdata?: scalar|null, // Default: true * cdata?: scalar|null, // Default: true
* }, * },
* array_collection?: array{ * array_collection?: array{

View File

@ -3,9 +3,10 @@
namespace PSC\Shop\BasketBundle\Api\Basket\Legacy; namespace PSC\Shop\BasketBundle\Api\Basket\Legacy;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Nelmio\ApiDocBundle\Annotation\Model; use Nelmio\ApiDocBundle\Attribute\Model;
use Nelmio\ApiDocBundle\Annotation\Security; use OpenApi\Attributes\JsonContent;
use OpenApi\Annotations as OA; use OpenApi\Attributes\RequestBody;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag; use OpenApi\Attributes\Tag;
use PSC\Component\ApiBundle\Dto\Error\NotFound; use PSC\Component\ApiBundle\Dto\Error\NotFound;
use PSC\Shop\BasketBundle\Dto\Legacy\Input; use PSC\Shop\BasketBundle\Dto\Legacy\Input;
@ -14,7 +15,6 @@ use PSC\Shop\BasketBundle\Event\Legacy\Add as PSCAdd;
use PSC\Shop\EntityBundle\Entity\Product; use PSC\Shop\EntityBundle\Entity\Product;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload; use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Attribute\Route;
@ -32,22 +32,11 @@ class Add extends AbstractController
) {} ) {}
/** /**
* change temp basketitem
*
* @deprecated * @deprecated
*
* @OA\Response(
* response=200,
* description="basket",
* @OA\JsonContent(ref=@Model(type=\PSC\Shop\BasketBundle\Dto\Legacy\Output::class))
* )
* @OA\RequestBody(
* description="This is a request body",
* @Model(type=\PSC\Shop\BasketBundle\Dto\Legacy\Input::class))
* )
* @OA\Tag(name="Basket")
*/ */
#[Tag('Basket')] #[Tag(name: 'Basket')]
#[Response(response: 200, description: 'basket', content: new JsonContent(ref: new Model(type: Output::class)))]
#[RequestBody(description: 'This is a request body', content: new Model(type: Input::class))]
#[Route(path: '/legacy/add', methods: ['POST'])] #[Route(path: '/legacy/add', methods: ['POST'])]
public function add(#[MapRequestPayload] Input $data): JsonResponse public function add(#[MapRequestPayload] Input $data): JsonResponse
{ {

View File

@ -3,9 +3,11 @@
namespace PSC\Shop\BasketBundle\Api\Basket\Legacy; namespace PSC\Shop\BasketBundle\Api\Basket\Legacy;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Nelmio\ApiDocBundle\Annotation\Model; use Nelmio\ApiDocBundle\Attribute\Model;
use Nelmio\ApiDocBundle\Annotation\Security; use OpenApi\Attributes\JsonContent;
use OpenApi\Annotations as OA; use OpenApi\Attributes\RequestBody;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use PSC\Component\ApiBundle\Dto\Error\NotFound; use PSC\Component\ApiBundle\Dto\Error\NotFound;
use PSC\Shop\BasketBundle\Dto\Legacy\Input; use PSC\Shop\BasketBundle\Dto\Legacy\Input;
use PSC\Shop\BasketBundle\Dto\Legacy\Output; use PSC\Shop\BasketBundle\Dto\Legacy\Output;
@ -13,12 +15,11 @@ use PSC\Shop\BasketBundle\Event\Legacy\Temp as PSCTemp;
use PSC\Shop\EntityBundle\Entity\Product; use PSC\Shop\EntityBundle\Entity\Product;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload; use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Yaml\Yaml;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
class Temp extends AbstractController class Temp extends AbstractController
@ -33,26 +34,17 @@ class Temp extends AbstractController
} }
/** /**
* change temp basketitem
* @deprecated * @deprecated
*
* @OA\Response(
* response=200,
* description="basket",
* @OA\JsonContent(ref=@Model(type=\PSC\Shop\BasketBundle\Dto\Legacy\Output::class))
* )
* @OA\RequestBody(
* description="This is a request body",
* @Model(type=\PSC\Shop\BasketBundle\Dto\Legacy\Input::class))
* )
* @OA\Tag(name="Basket")
*/ */
#[Tag(name: 'Basket')]
#[Response(response: 200, description: 'basket', content: new JsonContent(ref: new Model(type: Output::class)))]
#[RequestBody(description: 'This is a request body', content: new Model(type: Input::class))]
#[Route(path: '/legacy/temp', methods: ['POST'])] #[Route(path: '/legacy/temp', methods: ['POST'])]
public function temp(#[MapRequestPayload] Input $data): JsonResponse public function temp(#[MapRequestPayload] Input $data): JsonResponse
{ {
require_once(__DIR__ . '/../../../../EntityBundle/Lagacy/TP_Basket_Item.php'); require_once __DIR__ . '/../../../../EntityBundle/Lagacy/TP_Basket_Item.php';
require_once(__DIR__ . '/../../../../EntityBundle/Lagacy/TP_Basket_Collection.php'); require_once __DIR__ . '/../../../../EntityBundle/Lagacy/TP_Basket_Collection.php';
require_once(__DIR__ . '/../../../../EntityBundle/Lagacy/TP_Util.php'); require_once __DIR__ . '/../../../../EntityBundle/Lagacy/TP_Util.php';
$product = $this->entityManager->getRepository(Product::class)->findOneBy(['uuid' => $data->productUUId]); $product = $this->entityManager->getRepository(Product::class)->findOneBy(['uuid' => $data->productUUId]);
@ -61,7 +53,7 @@ class Temp extends AbstractController
$this->eventDispatcher->dispatch($event, PSCTemp::NAME); $this->eventDispatcher->dispatch($event, PSCTemp::NAME);
$basketItem = $_SESSION['Basket']['TempProduct'][$data->productUUId]; $basketItem = $_SESSION['Basket']['TempProduct'][$data->productUUId];
$basketItem->setXmlProduct((string)$data->xmlProduct); $basketItem->setXmlProduct((string) $data->xmlProduct);
$output = new Output(); $output = new Output();
$output->success = true; $output->success = true;
@ -70,6 +62,6 @@ class Temp extends AbstractController
return $this->json(new Output()); return $this->json(new Output());
} }
return $this->json(new NotFound("order not found")); return $this->json(new NotFound('order not found'));
} }
} }

View File

@ -3,9 +3,11 @@
namespace PSC\Shop\BasketBundle\Api\Basket\Legacy; namespace PSC\Shop\BasketBundle\Api\Basket\Legacy;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Nelmio\ApiDocBundle\Annotation\Model; use Nelmio\ApiDocBundle\Attribute\Model;
use Nelmio\ApiDocBundle\Annotation\Security; use OpenApi\Attributes\JsonContent;
use OpenApi\Annotations as OA; use OpenApi\Attributes\RequestBody;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use PSC\Component\ApiBundle\Dto\Error\NotFound; use PSC\Component\ApiBundle\Dto\Error\NotFound;
use PSC\Shop\BasketBundle\Dto\Legacy\Input; use PSC\Shop\BasketBundle\Dto\Legacy\Input;
use PSC\Shop\BasketBundle\Dto\Legacy\Output; use PSC\Shop\BasketBundle\Dto\Legacy\Output;
@ -13,12 +15,11 @@ use PSC\Shop\BasketBundle\Event\Legacy\Update as PSCUpdate;
use PSC\Shop\EntityBundle\Entity\Product; use PSC\Shop\EntityBundle\Entity\Product;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload; use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Yaml\Yaml;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
class Update extends AbstractController class Update extends AbstractController
@ -33,26 +34,17 @@ class Update extends AbstractController
} }
/** /**
* change temp basketitem
* @deprecated * @deprecated
*
* @OA\Response(
* response=200,
* description="basket",
* @OA\JsonContent(ref=@Model(type=\PSC\Shop\BasketBundle\Dto\Legacy\Output::class))
* )
* @OA\RequestBody(
* description="This is a request body",
* @Model(type=\PSC\Shop\BasketBundle\Dto\Legacy\Input::class))
* )
* @OA\Tag(name="Basket")
*/ */
#[Tag(name: 'Basket')]
#[Response(response: 200, description: 'basket', content: new JsonContent(ref: new Model(type: Output::class)))]
#[RequestBody(description: 'This is a request body', content: new Model(type: Input::class))]
#[Route(path: '/legacy/update', methods: ['POST'])] #[Route(path: '/legacy/update', methods: ['POST'])]
public function update(#[MapRequestPayload] Input $data): JsonResponse public function update(#[MapRequestPayload] Input $data): JsonResponse
{ {
require_once(__DIR__ . '/../../../../EntityBundle/Lagacy/TP_Basket_Item.php'); require_once __DIR__ . '/../../../../EntityBundle/Lagacy/TP_Basket_Item.php';
require_once(__DIR__ . '/../../../../EntityBundle/Lagacy/TP_Basket_Collection.php'); require_once __DIR__ . '/../../../../EntityBundle/Lagacy/TP_Basket_Collection.php';
require_once(__DIR__ . '/../../../../EntityBundle/Lagacy/TP_Util.php'); require_once __DIR__ . '/../../../../EntityBundle/Lagacy/TP_Util.php';
$product = $this->entityManager->getRepository(Product::class)->findOneBy(['uuid' => $data->productUUId]); $product = $this->entityManager->getRepository(Product::class)->findOneBy(['uuid' => $data->productUUId]);
@ -62,9 +54,9 @@ class Update extends AbstractController
$articles = $_SESSION['Basket']['Articles']; $articles = $_SESSION['Basket']['Articles'];
$basketItem = $_SESSION['Basket']['TempProduct'][$data->productUUId]; $basketItem = $_SESSION['Basket']['TempProduct'][$data->productUUId];
$basketItem->setDeliveryDate((string)$data->deliveryDate); $basketItem->setDeliveryDate((string) $data->deliveryDate);
$basketItem->setDeliveryInfo((string)$data->deliveryInfo); $basketItem->setDeliveryInfo((string) $data->deliveryInfo);
$basketItem->setXmlProduct((string)$data->xmlProduct); $basketItem->setXmlProduct((string) $data->xmlProduct);
$articles->updateItem($basketItem->getInLoad(), $basketItem); $articles->updateItem($basketItem->getInLoad(), $basketItem);
$output = new Output(); $output = new Output();
@ -76,6 +68,6 @@ class Update extends AbstractController
return $this->json(new Output()); return $this->json(new Output());
} }
return $this->json(new NotFound("order not found")); return $this->json(new NotFound('order not found'));
} }
} }

View File

@ -0,0 +1,50 @@
<?php
namespace PSC\Shop\BasketBundle\Api\Layouter;
use Doctrine\ORM\EntityManagerInterface;
use Nelmio\ApiDocBundle\Annotation\Model;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\RequestBody;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use PSC\Shop\BasketBundle\Dto\Layouter\Input;
use PSC\Shop\BasketBundle\Dto\Legacy\Output;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
class Save extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly EventDispatcherInterface $eventDispatcher,
private readonly TokenStorageInterface $tokenStorage,
) {}
/**
* change temp basketitem
*
* @deprecated
*/
#[Tag(name: 'Basket')]
#[Response(
response: 200,
description: 'basket',
content: new JsonContent(ref: new Model(type: Output::class))
)]
#[RequestBody(
description: 'This is a request body',
content: new Model(type: Input::class)
)]
#[Route(path: '/layouter/save', methods: ['POST'])]
public function save(#[MapRequestPayload] Input $data): JsonResponse
{
include_once __DIR__ . '/../../../../EntityBundle/Lagacy/TP_Basket_Item.php';
include_once __DIR__ . '/../../../../EntityBundle/Lagacy/TP_Basket_Collection.php';
include_once __DIR__ . '/../../../../EntityBundle/Lagacy/TP_Util.php';
}
}

View File

@ -0,0 +1,14 @@
<?php
namespace PSC\Shop\BasketBundle\Dto\Layouter;
use OpenApi\Attributes\Property;
class Input
{
#[Property(type: 'string')]
public string $productUUId = '';
#[Property(type: 'string')]
public string $layouterUUId = '';
}

View File

@ -2,70 +2,44 @@
namespace PSC\Shop\BasketBundle\Dto\Legacy; namespace PSC\Shop\BasketBundle\Dto\Legacy;
use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Attributes\Property;
use OpenApi\Annotations as OA;
class Input class Input
{ {
/** #[Property(type: 'integer')]
* @OA\Property(type="integer")
*/
public int $count = 1; public int $count = 1;
/** #[Property(type: 'string')]
* @OA\Property(type="string")
*/
public string $productUUId = ""; public string $productUUId = "";
/** #[Property(type: 'string')]
* @OA\Property(type="string")
*/
public string $uploadMode = "none"; public string $uploadMode = "none";
/** #[Property(type: 'string')]
* @OA\Property(type="string")
*/
public string $deliveryDate = ""; public string $deliveryDate = "";
/** #[Property(type: 'string')]
* @OA\Property(type="string")
*/
public string $basketField1 = ""; public string $basketField1 = "";
/** #[Property(type: 'string')]
* @OA\Property(type="string")
*/
public string $basketField2 = ""; public string $basketField2 = "";
#[Property(type: 'string')]
/**
* @OA\Property(type="string")
*/
public string $deliveryInfo = ""; public string $deliveryInfo = "";
/** #[Property(type: 'string')]
* @OA\Property(type="string")
*/
public string $xmlProduct = ""; public string $xmlProduct = "";
/** #[Property(type: 'bool')]
* @OA\Property(type="bool")
*/
public bool $dispatchNoEvents = false; public bool $dispatchNoEvents = false;
/** #[Property(type: 'bool')]
* @OA\Property(type="bool")
*/
public bool $clearTempItem = true; public bool $clearTempItem = true;
/** #[Property(type: 'string')]
* @OA\Property(type="string")
*/
public string $ref = ""; public string $ref = "";
/** #[Property(type: 'string')]
* @OA\Property(type="string")
*/
public string $layouterUuid = ""; public string $layouterUuid = "";