diff --git a/composer.json b/composer.json index 9648be9..65b31d3 100644 --- a/composer.json +++ b/composer.json @@ -24,8 +24,8 @@ }, "require": { "php": "^8.2", - "croct/plug-php": "0.1.0", - "croct/plug-symfony": "0.1.0" + "croct/plug-php": "0.2.0", + "croct/plug-symfony": "0.2.0" }, "require-dev": { "croct/coding-standard": "^0.4.5", diff --git a/composer.lock b/composer.lock index 14c1ef5..f41f682 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7d587bb8934203bc018998a361b1b274", + "content-hash": "4a8650fbf87e2f72d1e1e6d6c86b1f2a", "packages": [ { "name": "croct/plug-php", - "version": "0.1.0", + "version": "0.2.0", "source": { "type": "git", "url": "https://github.com/croct-tech/plug-php.git", - "reference": "82c38a93f303ba77ef1e066c284d7b949d8f8ac5" + "reference": "35f3a1826c5c9e6dcd2be164c35484e1085a4164" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/croct-tech/plug-php/zipball/82c38a93f303ba77ef1e066c284d7b949d8f8ac5", - "reference": "82c38a93f303ba77ef1e066c284d7b949d8f8ac5", + "url": "https://api.github.com/repos/croct-tech/plug-php/zipball/35f3a1826c5c9e6dcd2be164c35484e1085a4164", + "reference": "35f3a1826c5c9e6dcd2be164c35484e1085a4164", "shasum": "" }, "require": { @@ -97,24 +97,24 @@ "issues": "https://github.com/croct-tech/plug-php/issues", "source": "https://github.com/croct-tech/plug-php" }, - "time": "2026-06-17T17:59:03+00:00" + "time": "2026-06-19T19:23:59+00:00" }, { "name": "croct/plug-symfony", - "version": "0.1.0", + "version": "0.2.0", "source": { "type": "git", "url": "https://github.com/croct-tech/plug-symfony.git", - "reference": "341c9d29f8fdfa51835403d4c81cee7c36306bde" + "reference": "41f9a07e23454c6de943310704375c2293370e76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/croct-tech/plug-symfony/zipball/341c9d29f8fdfa51835403d4c81cee7c36306bde", - "reference": "341c9d29f8fdfa51835403d4c81cee7c36306bde", + "url": "https://api.github.com/repos/croct-tech/plug-symfony/zipball/41f9a07e23454c6de943310704375c2293370e76", + "reference": "41f9a07e23454c6de943310704375c2293370e76", "shasum": "" }, "require": { - "croct/plug-php": "0.1.0", + "croct/plug-php": "0.2.0", "ext-json": "*", "nyholm/psr7": "^1.8", "php": "^8.2", @@ -179,7 +179,7 @@ "issues": "https://github.com/croct-tech/plug-symfony/issues", "source": "https://github.com/croct-tech/plug-symfony" }, - "time": "2026-06-17T18:29:45+00:00" + "time": "2026-06-19T20:32:03+00:00" }, { "name": "graham-campbell/result-type", @@ -3881,22 +3881,22 @@ }, { "name": "guzzlehttp/guzzle", - "version": "7.12.0", + "version": "7.12.1", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "eaa81598031cf57a9e36258c8546defffc994cba" + "reference": "d34627490fbc03bf5c5d7cfed81f2faa19519425" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/eaa81598031cf57a9e36258c8546defffc994cba", - "reference": "eaa81598031cf57a9e36258c8546defffc994cba", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d34627490fbc03bf5c5d7cfed81f2faa19519425", + "reference": "d34627490fbc03bf5c5d7cfed81f2faa19519425", "shasum": "" }, "require": { "ext-json": "*", "guzzlehttp/promises": "^2.5", - "guzzlehttp/psr7": "^2.12", + "guzzlehttp/psr7": "^2.12.1", "php": "^7.2.5 || ^8.0", "psr/http-client": "^1.0", "symfony/deprecation-contracts": "^2.5 || ^3.0", @@ -3909,7 +3909,7 @@ "bamarni/composer-bin-plugin": "^1.8.2", "ext-curl": "*", "guzzle/client-integration-tests": "3.0.2", - "guzzlehttp/test-server": "^0.5", + "guzzlehttp/test-server": "^0.5.1", "php-http/message-factory": "^1.1", "phpunit/phpunit": "^8.5.52 || ^9.6.34", "psr/log": "^1.1 || ^2.0 || ^3.0" @@ -3989,7 +3989,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.12.0" + "source": "https://github.com/guzzle/guzzle/tree/7.12.1" }, "funding": [ { @@ -4005,7 +4005,7 @@ "type": "tidelift" } ], - "time": "2026-06-16T22:11:48+00:00" + "time": "2026-06-18T14:12:49+00:00" }, { "name": "guzzlehttp/promises", @@ -4093,16 +4093,16 @@ }, { "name": "guzzlehttp/psr7", - "version": "2.12.0", + "version": "2.12.1", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "9b38012e7b54f594707e6db52c684dc0a74b3a43" + "reference": "172ef2f4e9824c1e058b7f30be8ae25a02c0f2b7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/9b38012e7b54f594707e6db52c684dc0a74b3a43", - "reference": "9b38012e7b54f594707e6db52c684dc0a74b3a43", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/172ef2f4e9824c1e058b7f30be8ae25a02c0f2b7", + "reference": "172ef2f4e9824c1e058b7f30be8ae25a02c0f2b7", "shasum": "" }, "require": { @@ -4192,7 +4192,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.12.0" + "source": "https://github.com/guzzle/psr7/tree/2.12.1" }, "funding": [ { @@ -4208,7 +4208,7 @@ "type": "tidelift" } ], - "time": "2026-06-16T21:50:11+00:00" + "time": "2026-06-18T09:49:37+00:00" }, { "name": "justinrainbow/json-schema", diff --git a/croct.services.yml b/croct.services.yml index c43e0c7..f9b0274 100644 --- a/croct.services.yml +++ b/croct.services.yml @@ -32,6 +32,7 @@ services: - '@Drupal\croct\LanguageManagerLocaleResolver' - null - '@logger.channel.croct' + - '%croct.debug%' - 86400 - '@Drupal\croct\AccountIdentityResolver' tags: diff --git a/src/CroctServiceProvider.php b/src/CroctServiceProvider.php index 7aa23b8..309bc95 100644 --- a/src/CroctServiceProvider.php +++ b/src/CroctServiceProvider.php @@ -24,6 +24,10 @@ public function register(ContainerBuilder $container): void $container->setParameter('croct.app_id', self::setting('croct.app_id')); $container->setParameter('croct.api_key', self::setting('croct.api_key')); + // Forwards a debug flag to the browser SDK. Off by default; enable it in settings.php + // (where Drupal's other development toggles live) with $settings['croct.debug'] = true. + $container->setParameter('croct.debug', self::debug()); + // The SDK loader is served first-party from croct.script.url through CroctScriptProvider; // default to the CDN loader, allowing an override (e.g. a pinned version) via settings. $container->setParameter('croct.script.url', self::scriptUrl()); @@ -76,4 +80,9 @@ private static function storyblokEnabled(): bool { return Settings::get('croct.storyblok.enabled', true) !== false; } + + private static function debug(): bool + { + return Settings::get('croct.debug', false) === true; + } } diff --git a/tests/CroctServiceProviderTest.php b/tests/CroctServiceProviderTest.php index 98e7e05..0dcc511 100644 --- a/tests/CroctServiceProviderTest.php +++ b/tests/CroctServiceProviderTest.php @@ -37,6 +37,30 @@ public function testBridgesCredentialsFromSettings(): void self::assertSame('', $container->getParameter('croct.api_key')); } + #[TestDox('Defaults debug to off.')] + public function testDefaultsDebugOff(): void + { + new Settings([]); + + $container = new ContainerBuilder(); + + (new CroctServiceProvider())->register($container); + + self::assertFalse($container->getParameter('croct.debug')); + } + + #[TestDox('Enables debug through settings.')] + public function testEnablesDebugThroughSettings(): void + { + new Settings(['croct.debug' => true]); + + $container = new ContainerBuilder(); + + (new CroctServiceProvider())->register($container); + + self::assertTrue($container->getParameter('croct.debug')); + } + #[TestDox('Defaults the loader URL to the CDN script.')] public function testDefaultsScriptUrl(): void {