diff --git a/composer.json b/composer.json index 8f9139ae0..260bdd9bd 100644 --- a/composer.json +++ b/composer.json @@ -43,9 +43,7 @@ "autoload": { "psr-4": { "Kiener\\MolliePayments\\": "src/", - "Mollie\\Api\\": "vendor_manual/mollie/mollie-api-php/src/", - "Shopware\\Core\\": "polyfill/Shopware/Core/", - "MolliePayments\\Fixtures\\": "tests/Fixtures/" + "Mollie\\Api\\": "vendor_manual/mollie/mollie-api-php/src/" } }, "autoload-dev": { diff --git a/composer.lock b/composer.lock index 3f9b5b026..44de21b70 100644 --- a/composer.lock +++ b/composer.lock @@ -63,16 +63,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.308.1", + "version": "3.308.6", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "bf5f1221d4c5c67d3213150fb91dfb5ce627227b" + "reference": "d119265faba226b3fab1514b6fa27a2986b91453" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/bf5f1221d4c5c67d3213150fb91dfb5ce627227b", - "reference": "bf5f1221d4c5c67d3213150fb91dfb5ce627227b", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/d119265faba226b3fab1514b6fa27a2986b91453", + "reference": "d119265faba226b3fab1514b6fa27a2986b91453", "shasum": "" }, "require": { @@ -152,9 +152,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.308.1" + "source": "https://github.com/aws/aws-sdk-php/tree/3.308.6" }, - "time": "2024-05-22T18:05:56+00:00" + "time": "2024-05-30T18:08:56+00:00" }, { "name": "boxblinkracer/phpunuhi", @@ -162,12 +162,12 @@ "source": { "type": "git", "url": "https://github.com/boxblinkracer/phpunuhi.git", - "reference": "6cf63848137db6f3e992e224a6ad20a2a6132e2f" + "reference": "85899a406d6844a9cd99822b227a10200fa24846" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/boxblinkracer/phpunuhi/zipball/6cf63848137db6f3e992e224a6ad20a2a6132e2f", - "reference": "6cf63848137db6f3e992e224a6ad20a2a6132e2f", + "url": "https://api.github.com/repos/boxblinkracer/phpunuhi/zipball/85899a406d6844a9cd99822b227a10200fa24846", + "reference": "85899a406d6844a9cd99822b227a10200fa24846", "shasum": "" }, "require": { @@ -226,9 +226,9 @@ ], "support": { "issues": "https://github.com/boxblinkracer/phpunuhi/issues", - "source": "https://github.com/boxblinkracer/phpunuhi/tree/v1.20.0" + "source": "https://github.com/boxblinkracer/phpunuhi/tree/main" }, - "time": "2024-05-18T07:25:41+00:00" + "time": "2024-05-31T05:49:41+00:00" }, { "name": "brick/math", @@ -5340,16 +5340,16 @@ }, { "name": "orhanerday/open-ai", - "version": "5.1", + "version": "5.2", "source": { "type": "git", "url": "https://github.com/orhanerday/open-ai.git", - "reference": "386c7f65a50cbfb0fbdbebcd72f7e6c7a6039c84" + "reference": "d8c78fe2f5fed59e0ba458f90b5589ed9f13a367" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/orhanerday/open-ai/zipball/386c7f65a50cbfb0fbdbebcd72f7e6c7a6039c84", - "reference": "386c7f65a50cbfb0fbdbebcd72f7e6c7a6039c84", + "url": "https://api.github.com/repos/orhanerday/open-ai/zipball/d8c78fe2f5fed59e0ba458f90b5589ed9f13a367", + "reference": "d8c78fe2f5fed59e0ba458f90b5589ed9f13a367", "shasum": "" }, "require": { @@ -5387,7 +5387,7 @@ ], "support": { "issues": "https://github.com/orhanerday/open-ai/issues", - "source": "https://github.com/orhanerday/open-ai/tree/5.1" + "source": "https://github.com/orhanerday/open-ai/tree/5.2" }, "funding": [ { @@ -5395,7 +5395,7 @@ "type": "github" } ], - "time": "2024-01-25T06:43:19+00:00" + "time": "2024-05-29T12:31:54+00:00" }, { "name": "padaliyajay/php-autoprefixer", diff --git a/src/Compatibility/DependencyLoader.php b/src/Compatibility/DependencyLoader.php index c618c92c8..215682946 100644 --- a/src/Compatibility/DependencyLoader.php +++ b/src/Compatibility/DependencyLoader.php @@ -51,16 +51,34 @@ public function loadServices(): void $loader->load('compatibility/flowbuilder/6.4.6.0.xml'); } + if ($this->shouldLoadFixtures()) { + $loader->load('services/fixtures/fixtures.xml'); + } + } - $composerDevReqsInstalled = file_exists(__DIR__.'/../../vendor/bin/phpunit'); + public function registerFixturesAutoloader():void + { + if ($this->shouldLoadFixtures() === false) { + return; + } - if ($composerDevReqsInstalled) { - $dirFixtures = (string)realpath(__DIR__ . '/../../tests/Fixtures/'); + $dirFixtures = (string)realpath(__DIR__ . '/../../tests/Fixtures/'); + # we need to tell Shopware to load our custom fixtures + # from our TEST autoload-dev area.... + $classLoader = new ClassLoader(); + $classLoader->addPsr4("MolliePayments\\Fixtures\\", $dirFixtures, true); - if (is_dir($dirFixtures)) { - $loader->load('services/fixtures/fixtures.xml'); - } + $classLoader->register(); + } + + private function shouldLoadFixtures():bool + { + $composerDevReqsInstalled = file_exists(__DIR__.'/../../vendor/bin/phpunit'); + if ($composerDevReqsInstalled === false) { + return false; } + $dirFixtures = (string)realpath(__DIR__ . '/../../tests/Fixtures/'); + return is_dir($dirFixtures); } /** diff --git a/src/MolliePayments.php b/src/MolliePayments.php index c112d04d5..810ec9761 100644 --- a/src/MolliePayments.php +++ b/src/MolliePayments.php @@ -103,6 +103,27 @@ public function activate(ActivateContext $context): void $this->runDbMigrations($context->getMigrationCollection()); } + public function boot(): void + { + parent::boot(); + + if ($this->container === null) { + return; + } + /** @var Container $container */ + $container = $this->container; + + $shopwareVersion = $container->getParameter('kernel.shopware_version'); + if (!is_string($shopwareVersion)) { + $shopwareVersion = Kernel::SHOPWARE_FALLBACK_VERSION; + } + # load the dependencies that are compatible + # with our current shopware version + + $loader = new DependencyLoader($container, new VersionCompare($shopwareVersion)); + $loader->registerFixturesAutoloader(); + } + /** * @param Context $context diff --git a/switch-composer.php b/switch-composer.php index 7903307b0..3d9a788a4 100644 --- a/switch-composer.php +++ b/switch-composer.php @@ -36,8 +36,6 @@ function moveToDev(array $composerContent, string $swVersion) unset($composerContent['require']["shopware/administration"]); unset($composerContent['require']["shopware/storefront"]); - $composerContent['autoload']['psr-4']['MolliePayments\\Fixtures\\'] = "tests/Fixtures/"; - return $composerContent; } @@ -56,6 +54,5 @@ function moveToProd(array $composerContent, string $swVersion) unset($composerContent['require-dev']["shopware/administration"]); unset($composerContent['require-dev']["shopware/storefront"]); - unset($composerContent['autoload']['psr-4']['MolliePayments\\Fixtures\\']); return $composerContent; }