From 40834a8bd68f0a9474f285b87b44153f33712f52 Mon Sep 17 00:00:00 2001 From: Simon Kuehn Date: Tue, 19 May 2026 13:58:48 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20eBay=20config=20CRUD=20=E2=80=94=20overr?= =?UTF-8?q?ide=20createEntity()=20for=20required=20constructor=20args?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EasyAdmin calls new ArticleTypePlatformConfig() with no args. Fix: - Add setArticleType() setter to the entity - Override createEntity() in the CRUD controller to inject the eBay Platform and first available ArticleType as placeholder (form overwrites both) Co-Authored-By: Claude Sonnet 4.6 --- .../Channel/ArticleTypePlatformConfig.php | 5 +++++ ...rticleTypePlatformConfigCrudController.php | 22 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Domain/Channel/ArticleTypePlatformConfig.php b/src/Domain/Channel/ArticleTypePlatformConfig.php index a91b12c..834a91c 100644 --- a/src/Domain/Channel/ArticleTypePlatformConfig.php +++ b/src/Domain/Channel/ArticleTypePlatformConfig.php @@ -65,6 +65,11 @@ class ArticleTypePlatformConfig return $this->articleType; } + public function setArticleType(ArticleType $articleType): void + { + $this->articleType = $articleType; + } + public function getPlatform(): Platform { return $this->platform; diff --git a/src/Infrastructure/Http/Controller/Admin/EbayArticleTypePlatformConfigCrudController.php b/src/Infrastructure/Http/Controller/Admin/EbayArticleTypePlatformConfigCrudController.php index b3d9bd2..630f8f5 100644 --- a/src/Infrastructure/Http/Controller/Admin/EbayArticleTypePlatformConfigCrudController.php +++ b/src/Infrastructure/Http/Controller/Admin/EbayArticleTypePlatformConfigCrudController.php @@ -4,7 +4,9 @@ declare(strict_types=1); namespace App\Infrastructure\Http\Controller\Admin; +use App\Domain\Article\Repository\ArticleTypeRepositoryInterface; use App\Domain\Channel\ArticleTypePlatformConfig; +use App\Domain\Channel\Repository\PlatformRepositoryInterface; use App\Infrastructure\Channel\Ebay\EbayPolicyProvider; use Doctrine\ORM\QueryBuilder; use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; @@ -21,8 +23,26 @@ use EasyCorp\Bundle\EasyAdminBundle\Orm\EntityRepository; /** @extends AbstractCrudController */ final class EbayArticleTypePlatformConfigCrudController extends AbstractCrudController { - public function __construct(private readonly EbayPolicyProvider $policyProvider) + public function __construct( + private readonly EbayPolicyProvider $policyProvider, + private readonly PlatformRepositoryInterface $platformRepository, + private readonly ArticleTypeRepositoryInterface $articleTypeRepository, + ) { + } + + public function createEntity(string $entityFqcn): ArticleTypePlatformConfig { + $platform = $this->platformRepository->findByType('ebay'); + if (null === $platform) { + throw new \RuntimeException('eBay-Platform nicht in der Datenbank konfiguriert. Bitte zuerst eine Platform mit type="ebay" anlegen.'); + } + + $articleTypes = $this->articleTypeRepository->findAll(); + if ([] === $articleTypes) { + throw new \RuntimeException('Kein Artikeltyp vorhanden. Bitte zuerst einen Artikeltyp anlegen.'); + } + + return new ArticleTypePlatformConfig($articleTypes[0], $platform, ''); } public static function getEntityFqcn(): string