From 61b1a06fb8915b18731bcc65349b365cdcc3ac8a Mon Sep 17 00:00:00 2001 From: Michael Lee <lee.5151@osu.edu> Date: Mon, 12 Sep 2022 11:33:07 -0400 Subject: [PATCH] Installing drupal/google_analytics (4.0.2) --- composer.json | 3 - composer.lock | 30 +- vendor/composer/installed.json | 35 ++- vendor/composer/installed.php | 16 +- .../.github/workflows/ci.yml | 49 ---- .../psr-http-message-bridge/.gitignore | 6 - .../psr-http-message-bridge/.php_cs.dist | 24 -- .../psr-http-message-bridge/CHANGELOG.md | 5 + .../Factory/PsrHttpFactory.php | 12 +- .../Factory/UploadedFile.php | 2 +- .../PsrServerRequestResolverTest.php | 68 ----- .../EventListener/PsrResponseListenerTest.php | 53 ---- .../AbstractHttpMessageFactoryTest.php | 234 --------------- .../Factory/HttpFoundationFactoryTest.php | 272 ------------------ .../Tests/Factory/PsrHttpFactoryTest.php | 30 -- .../App/Controller/PsrRequestController.php | 45 --- .../Tests/Fixtures/App/Kernel.php | 76 ----- .../Tests/Fixtures/App/Kernel44.php | 67 ----- .../Tests/Fixtures/Message.php | 118 -------- .../Tests/Fixtures/Response.php | 48 ---- .../Tests/Fixtures/ServerRequest.php | 202 ------------- .../Tests/Fixtures/Stream.php | 108 ------- .../Tests/Fixtures/UploadedFile.php | 65 ----- .../Tests/Fixtures/Uri.php | 170 ----------- .../Tests/Functional/ControllerTest.php | 55 ---- .../Tests/Functional/CovertTest.php | 237 --------------- .../psr-http-message-bridge/phpunit.xml.dist | 29 -- web/modules/google_analytics/composer.json | 3 - .../install/google_analytics.settings.yml | 1 - .../config/schema/google_analytics.schema.yml | 3 - .../google_analytics.info.yml | 9 +- .../google_analytics/google_analytics.install | 13 +- .../google_analytics/google_analytics.module | 36 +-- .../google_analytics.services.yml | 16 +- .../d6_google_analytics_settings.yml | 7 +- .../d7_google_analytics_settings.yml | 9 +- .../GoogleAnalyticsJavaScriptSnippet.php | 1 + .../src/Constants/GoogleAnalyticsPatterns.php | 4 +- .../src/Event/GoogleAnalyticsConfigEvent.php | 5 +- .../src/Event/GoogleAnalyticsEventsEvent.php | 2 +- .../src/Event/PagePathEvent.php | 2 +- .../GoogleAnalyticsConfig/CustomConfig.php | 14 +- .../GoogleAnalyticsConfig/DefaultConfig.php | 8 +- .../PagePath/ContentTranslation.php | 15 +- .../EventSubscriber/PagePath/HttpStatus.php | 9 +- .../PagePath/InvalidUserLogin.php | 17 +- .../src/EventSubscriber/PagePath/Search.php | 13 +- .../Form/GoogleAnalyticsAdminSettingsForm.php | 7 +- .../src/JavascriptLocalCache.php | 11 +- .../process/GoogleAnalyticsParameterPages.php | 93 ++++++ .../GoogleAnalyticsVisibilityPages.php | 2 +- .../GoogleAnalyticsVisibilityRoles.php | 2 +- .../google_analytics_test.info.yml | 6 +- .../Functional/GoogleAnalyticsBasicTest.php | 14 +- ...nalyticsCustomDimensionsAndMetricsTest.php | 6 +- .../Functional/GoogleAnalyticsCustomUrls.php | 4 +- .../Functional/GoogleAnalyticsRolesTest.php | 4 +- .../Functional/GoogleAnalyticsSearchTest.php | 7 +- .../GoogleAnalyticsStatusMessagesTest.php | 4 +- .../GoogleAnalyticsUninstallTest.php | 4 +- .../GoogleAnalyticsUserFieldsTest.php | 4 +- .../GoogleAnalyticsFormValidationTest.php | 2 +- .../GoogleAnalyticsAdminSettingsFormTest.php | 2 +- 63 files changed, 286 insertions(+), 2132 deletions(-) delete mode 100644 vendor/symfony/psr-http-message-bridge/.github/workflows/ci.yml delete mode 100644 vendor/symfony/psr-http-message-bridge/.gitignore delete mode 100644 vendor/symfony/psr-http-message-bridge/.php_cs.dist delete mode 100644 vendor/symfony/psr-http-message-bridge/Tests/ArgumentValueResolver/PsrServerRequestResolverTest.php delete mode 100644 vendor/symfony/psr-http-message-bridge/Tests/EventListener/PsrResponseListenerTest.php delete mode 100644 vendor/symfony/psr-http-message-bridge/Tests/Factory/AbstractHttpMessageFactoryTest.php delete mode 100644 vendor/symfony/psr-http-message-bridge/Tests/Factory/HttpFoundationFactoryTest.php delete mode 100644 vendor/symfony/psr-http-message-bridge/Tests/Factory/PsrHttpFactoryTest.php delete mode 100644 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/App/Controller/PsrRequestController.php delete mode 100644 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/App/Kernel.php delete mode 100644 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/App/Kernel44.php delete mode 100644 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Message.php delete mode 100644 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Response.php delete mode 100644 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/ServerRequest.php delete mode 100644 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Stream.php delete mode 100644 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/UploadedFile.php delete mode 100644 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Uri.php delete mode 100644 vendor/symfony/psr-http-message-bridge/Tests/Functional/ControllerTest.php delete mode 100644 vendor/symfony/psr-http-message-bridge/Tests/Functional/CovertTest.php delete mode 100644 vendor/symfony/psr-http-message-bridge/phpunit.xml.dist create mode 100644 web/modules/google_analytics/src/Plugin/migrate/process/GoogleAnalyticsParameterPages.php diff --git a/composer.json b/composer.json index 981336c14f..bd96444058 100644 --- a/composer.json +++ b/composer.json @@ -288,9 +288,6 @@ "drupal/entity_clone": { "3060223": "https://www.drupal.org/files/issues/2019-10-17/%20entity_clone-corrupted-paragraph-cloning-3060223-5.patch" }, - "drupal/google_analytics": { - "3246597": "https://www.drupal.org/files/issues/2021-11-08/google_analytics-3246597-3-with-packaging-info.patch" - }, "drupal/honeypot": { "2811189": "https://www.drupal.org/files/issues/2022-05-25/honeypot-field_weight-2811189-27_0.patch" }, diff --git a/composer.lock b/composer.lock index 7aabbfe6b3..80841ea591 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4228709f0ab3ac80ac42663dbf20b289", + "content-hash": "c5d896ad20807061033faebd641722c3", "packages": [ { "name": "alchemy/zippy", @@ -4461,20 +4461,20 @@ }, { "name": "drupal/google_analytics", - "version": "4.0.0", + "version": "4.0.2", "source": { "type": "git", "url": "https://git.drupalcode.org/project/google_analytics.git", - "reference": "4.0.0" + "reference": "4.0.2" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/google_analytics-4.0.0.zip", - "reference": "4.0.0", - "shasum": "4f761d4c852d11966f7289b0eb6431cc8db27240" + "url": "https://ftp.drupal.org/files/projects/google_analytics-4.0.2.zip", + "reference": "4.0.2", + "shasum": "6deec511373e4659e42ff494c8729434728e37d7" }, "require": { - "drupal/core": "^8.9|^9.0" + "drupal/core": "^9.3 || ^10" }, "require-dev": { "drupal/token": "^1.7" @@ -4482,8 +4482,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "4.0.0", - "datestamp": "1634230238", + "version": "4.0.2", + "datestamp": "1662768595", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" @@ -14493,16 +14493,16 @@ }, { "name": "symfony/psr-http-message-bridge", - "version": "v2.1.2", + "version": "v2.1.3", "source": { "type": "git", "url": "https://github.com/symfony/psr-http-message-bridge.git", - "reference": "22b37c8a3f6b5d94e9cdbd88e1270d96e2f97b34" + "reference": "d444f85dddf65c7e57c58d8e5b3a4dbb593b1840" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/22b37c8a3f6b5d94e9cdbd88e1270d96e2f97b34", - "reference": "22b37c8a3f6b5d94e9cdbd88e1270d96e2f97b34", + "url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/d444f85dddf65c7e57c58d8e5b3a4dbb593b1840", + "reference": "d444f85dddf65c7e57c58d8e5b3a4dbb593b1840", "shasum": "" }, "require": { @@ -14561,7 +14561,7 @@ ], "support": { "issues": "https://github.com/symfony/psr-http-message-bridge/issues", - "source": "https://github.com/symfony/psr-http-message-bridge/tree/v2.1.2" + "source": "https://github.com/symfony/psr-http-message-bridge/tree/v2.1.3" }, "funding": [ { @@ -14577,7 +14577,7 @@ "type": "tidelift" } ], - "time": "2021-11-05T13:13:39+00:00" + "time": "2022-09-05T10:34:54+00:00" }, { "name": "symfony/routing", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index f3dcf9ffe3..fb0d7508a5 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -4613,21 +4613,21 @@ }, { "name": "drupal/google_analytics", - "version": "4.0.0", - "version_normalized": "4.0.0.0", + "version": "4.0.2", + "version_normalized": "4.0.2.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/google_analytics.git", - "reference": "4.0.0" + "reference": "4.0.2" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/google_analytics-4.0.0.zip", - "reference": "4.0.0", - "shasum": "4f761d4c852d11966f7289b0eb6431cc8db27240" + "url": "https://ftp.drupal.org/files/projects/google_analytics-4.0.2.zip", + "reference": "4.0.2", + "shasum": "6deec511373e4659e42ff494c8729434728e37d7" }, "require": { - "drupal/core": "^8.9|^9.0" + "drupal/core": "^9.3 || ^10" }, "require-dev": { "drupal/token": "^1.7" @@ -4635,8 +4635,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "4.0.0", - "datestamp": "1634230238", + "version": "4.0.2", + "datestamp": "1662768595", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" @@ -4644,9 +4644,6 @@ }, "branch-alias": { "dev-4.x": "4.x-dev" - }, - "patches_applied": { - "3246597": "https://www.drupal.org/files/issues/2021-11-08/google_analytics-3246597-3-with-packaging-info.patch" } }, "installation-source": "dist", @@ -14929,17 +14926,17 @@ }, { "name": "symfony/psr-http-message-bridge", - "version": "v2.1.2", - "version_normalized": "2.1.2.0", + "version": "v2.1.3", + "version_normalized": "2.1.3.0", "source": { "type": "git", "url": "https://github.com/symfony/psr-http-message-bridge.git", - "reference": "22b37c8a3f6b5d94e9cdbd88e1270d96e2f97b34" + "reference": "d444f85dddf65c7e57c58d8e5b3a4dbb593b1840" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/22b37c8a3f6b5d94e9cdbd88e1270d96e2f97b34", - "reference": "22b37c8a3f6b5d94e9cdbd88e1270d96e2f97b34", + "url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/d444f85dddf65c7e57c58d8e5b3a4dbb593b1840", + "reference": "d444f85dddf65c7e57c58d8e5b3a4dbb593b1840", "shasum": "" }, "require": { @@ -14960,7 +14957,7 @@ "suggest": { "nyholm/psr7": "For a super lightweight PSR-7/17 implementation" }, - "time": "2021-11-05T13:13:39+00:00", + "time": "2022-09-05T10:34:54+00:00", "type": "symfony-bridge", "extra": { "branch-alias": { @@ -15000,7 +14997,7 @@ ], "support": { "issues": "https://github.com/symfony/psr-http-message-bridge/issues", - "source": "https://github.com/symfony/psr-http-message-bridge/tree/v2.1.2" + "source": "https://github.com/symfony/psr-http-message-bridge/tree/v2.1.3" }, "funding": [ { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 49f1402bf3..0439cd5d02 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'osu-asc-webservices/d8-upstream', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '12d60e4801ab2fd486c3d0e24651b3963945ed43', + 'reference' => '7584256fde162dfee5d9acb7f5c97e6d9d29695e', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -821,9 +821,9 @@ 'dev_requirement' => false, ), 'drupal/google_analytics' => array( - 'pretty_version' => '4.0.0', - 'version' => '4.0.0.0', - 'reference' => '4.0.0', + 'pretty_version' => '4.0.2', + 'version' => '4.0.2.0', + 'reference' => '4.0.2', 'type' => 'drupal-module', 'install_path' => __DIR__ . '/../../web/modules/google_analytics', 'aliases' => array(), @@ -1594,7 +1594,7 @@ 'osu-asc-webservices/d8-upstream' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '12d60e4801ab2fd486c3d0e24651b3963945ed43', + 'reference' => '7584256fde162dfee5d9acb7f5c97e6d9d29695e', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -2340,9 +2340,9 @@ 'dev_requirement' => false, ), 'symfony/psr-http-message-bridge' => array( - 'pretty_version' => 'v2.1.2', - 'version' => '2.1.2.0', - 'reference' => '22b37c8a3f6b5d94e9cdbd88e1270d96e2f97b34', + 'pretty_version' => 'v2.1.3', + 'version' => '2.1.3.0', + 'reference' => 'd444f85dddf65c7e57c58d8e5b3a4dbb593b1840', 'type' => 'symfony-bridge', 'install_path' => __DIR__ . '/../symfony/psr-http-message-bridge', 'aliases' => array(), diff --git a/vendor/symfony/psr-http-message-bridge/.github/workflows/ci.yml b/vendor/symfony/psr-http-message-bridge/.github/workflows/ci.yml deleted file mode 100644 index 4c0e8aeefe..0000000000 --- a/vendor/symfony/psr-http-message-bridge/.github/workflows/ci.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: CI - -on: - pull_request: - push: - -jobs: - test: - name: 'Test ${{ matrix.deps }} on PHP ${{ matrix.php }}' - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - php: ['7.1.3', '7.2', '7.3', '7.4', '8.0', '8.1'] - include: - - php: '7.4' - deps: lowest - deprecations: max[self]=0 - - php: '8.0' - deps: highest - deprecations: max[indirect]=5 - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '${{ matrix.php }}' - coverage: none - - - name: Configure composer - if: "${{ matrix.deps == 'highest' }}" - run: composer config minimum-stability dev - - - name: Composer install - uses: ramsey/composer-install@v1 - with: - dependency-versions: '${{ matrix.deps }}' - - - name: Install PHPUnit - run: vendor/bin/simple-phpunit install - - - name: Run tests - run: vendor/bin/simple-phpunit - env: - SYMFONY_DEPRECATIONS_HELPER: '${{ matrix.deprecations }}' diff --git a/vendor/symfony/psr-http-message-bridge/.gitignore b/vendor/symfony/psr-http-message-bridge/.gitignore deleted file mode 100644 index 55ce5dd254..0000000000 --- a/vendor/symfony/psr-http-message-bridge/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -vendor/ -composer.lock -phpunit.xml -.php_cs.cache -.phpunit.result.cache -/Tests/Fixtures/App/var diff --git a/vendor/symfony/psr-http-message-bridge/.php_cs.dist b/vendor/symfony/psr-http-message-bridge/.php_cs.dist deleted file mode 100644 index d741d39f5d..0000000000 --- a/vendor/symfony/psr-http-message-bridge/.php_cs.dist +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -return PhpCsFixer\Config::create() - ->setRules([ - '@Symfony' => true, - '@Symfony:risky' => true, - '@PHPUnit48Migration:risky' => true, - 'php_unit_no_expectation_annotation' => false, // part of `PHPUnitXYMigration:risky` ruleset, to be enabled when PHPUnit 4.x support will be dropped, as we don't want to rewrite exceptions handling twice - 'array_syntax' => ['syntax' => 'short'], - 'fopen_flags' => false, - 'ordered_imports' => true, - 'protected_to_private' => false, - // Part of @Symfony:risky in PHP-CS-Fixer 2.13.0. To be removed from the config file once upgrading - 'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'], - // Part of future @Symfony ruleset in PHP-CS-Fixer To be removed from the config file once upgrading - 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], - ]) - ->setRiskyAllowed(true) - ->setFinder( - PhpCsFixer\Finder::create() - ->in(__DIR__) - ->name('*.php') - ) -; diff --git a/vendor/symfony/psr-http-message-bridge/CHANGELOG.md b/vendor/symfony/psr-http-message-bridge/CHANGELOG.md index c17d8f342b..87816cc9aa 100644 --- a/vendor/symfony/psr-http-message-bridge/CHANGELOG.md +++ b/vendor/symfony/psr-http-message-bridge/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +# 2.1.3 (2022-09-05) + +* Ignore invalid HTTP headers when creating PSR7 objects +* Fix for wrong type passed to `moveTo()` + # 2.1.2 (2021-11-05) * Allow Symfony 6 diff --git a/vendor/symfony/psr-http-message-bridge/Factory/PsrHttpFactory.php b/vendor/symfony/psr-http-message-bridge/Factory/PsrHttpFactory.php index d19baa1abe..61650df9f6 100644 --- a/vendor/symfony/psr-http-message-bridge/Factory/PsrHttpFactory.php +++ b/vendor/symfony/psr-http-message-bridge/Factory/PsrHttpFactory.php @@ -58,7 +58,11 @@ public function createRequest(Request $symfonyRequest) ); foreach ($symfonyRequest->headers->all() as $name => $value) { - $request = $request->withHeader($name, $value); + try { + $request = $request->withHeader($name, $value); + } catch (\InvalidArgumentException $e) { + // ignore invalid header + } } $body = $this->streamFactory->createStreamFromResource($symfonyRequest->getContent(true)); @@ -160,7 +164,11 @@ public function createResponse(Response $symfonyResponse) } foreach ($headers as $name => $value) { - $response = $response->withHeader($name, $value); + try { + $response = $response->withHeader($name, $value); + } catch (\InvalidArgumentException $e) { + // ignore invalid header + } } $protocolVersion = $symfonyResponse->getProtocolVersion(); diff --git a/vendor/symfony/psr-http-message-bridge/Factory/UploadedFile.php b/vendor/symfony/psr-http-message-bridge/Factory/UploadedFile.php index 53aa37a622..b9510455c3 100644 --- a/vendor/symfony/psr-http-message-bridge/Factory/UploadedFile.php +++ b/vendor/symfony/psr-http-message-bridge/Factory/UploadedFile.php @@ -61,7 +61,7 @@ public function move($directory, $name = null): File $target = $this->getTargetFile($directory, $name); try { - $this->psrUploadedFile->moveTo($target); + $this->psrUploadedFile->moveTo((string) $target); } catch (\RuntimeException $e) { throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, $e->getMessage()), 0, $e); } diff --git a/vendor/symfony/psr-http-message-bridge/Tests/ArgumentValueResolver/PsrServerRequestResolverTest.php b/vendor/symfony/psr-http-message-bridge/Tests/ArgumentValueResolver/PsrServerRequestResolverTest.php deleted file mode 100644 index 662b18691c..0000000000 --- a/vendor/symfony/psr-http-message-bridge/Tests/ArgumentValueResolver/PsrServerRequestResolverTest.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PsrHttpMessage\Tests\ArgumentValueResolver; - -use PHPUnit\Framework\TestCase; -use Psr\Http\Message\MessageInterface; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ServerRequestInterface; -use Symfony\Bridge\PsrHttpMessage\ArgumentValueResolver\PsrServerRequestResolver; -use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentResolver; - -/** - * @author Alexander M. Turek <me@derrabus.de> - */ -final class PsrServerRequestResolverTest extends TestCase -{ - public function testServerRequest() - { - $symfonyRequest = $this->createMock(Request::class); - $psrRequest = $this->createMock(ServerRequestInterface::class); - - $resolver = $this->bootstrapResolver($symfonyRequest, $psrRequest); - - self::assertSame([$psrRequest], $resolver->getArguments($symfonyRequest, static function (ServerRequestInterface $serverRequest): void {})); - } - - public function testRequest() - { - $symfonyRequest = $this->createMock(Request::class); - $psrRequest = $this->createMock(ServerRequestInterface::class); - - $resolver = $this->bootstrapResolver($symfonyRequest, $psrRequest); - - self::assertSame([$psrRequest], $resolver->getArguments($symfonyRequest, static function (RequestInterface $request): void {})); - } - - public function testMessage() - { - $symfonyRequest = $this->createMock(Request::class); - $psrRequest = $this->createMock(ServerRequestInterface::class); - - $resolver = $this->bootstrapResolver($symfonyRequest, $psrRequest); - - self::assertSame([$psrRequest], $resolver->getArguments($symfonyRequest, static function (MessageInterface $request): void {})); - } - - private function bootstrapResolver(Request $symfonyRequest, ServerRequestInterface $psrRequest): ArgumentResolver - { - $messageFactory = $this->createMock(HttpMessageFactoryInterface::class); - $messageFactory->expects(self::once()) - ->method('createRequest') - ->with(self::identicalTo($symfonyRequest)) - ->willReturn($psrRequest); - - return new ArgumentResolver(null, [new PsrServerRequestResolver($messageFactory)]); - } -} diff --git a/vendor/symfony/psr-http-message-bridge/Tests/EventListener/PsrResponseListenerTest.php b/vendor/symfony/psr-http-message-bridge/Tests/EventListener/PsrResponseListenerTest.php deleted file mode 100644 index 9a94b20aca..0000000000 --- a/vendor/symfony/psr-http-message-bridge/Tests/EventListener/PsrResponseListenerTest.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PsrHttpMessage\Tests\EventListener; - -use PHPUnit\Framework\TestCase; -use Symfony\Bridge\PsrHttpMessage\EventListener\PsrResponseListener; -use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Response; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Event\ViewEvent; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * @author Kévin Dunglas <dunglas@gmail.com> - */ -class PsrResponseListenerTest extends TestCase -{ - public function testConvertsControllerResult() - { - $listener = new PsrResponseListener(); - $event = $this->createEventMock(new Response()); - $listener->onKernelView($event); - - self::assertTrue($event->hasResponse()); - } - - public function testDoesNotConvertControllerResult() - { - $listener = new PsrResponseListener(); - $event = $this->createEventMock([]); - - $listener->onKernelView($event); - self::assertFalse($event->hasResponse()); - - $event = $this->createEventMock(null); - - $listener->onKernelView($event); - self::assertFalse($event->hasResponse()); - } - - private function createEventMock($controllerResult): ViewEvent - { - return new ViewEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MASTER_REQUEST, $controllerResult); - } -} diff --git a/vendor/symfony/psr-http-message-bridge/Tests/Factory/AbstractHttpMessageFactoryTest.php b/vendor/symfony/psr-http-message-bridge/Tests/Factory/AbstractHttpMessageFactoryTest.php deleted file mode 100644 index 82d3fc7893..0000000000 --- a/vendor/symfony/psr-http-message-bridge/Tests/Factory/AbstractHttpMessageFactoryTest.php +++ /dev/null @@ -1,234 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PsrHttpMessage\Tests\Factory; - -use PHPUnit\Framework\TestCase; -use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface; -use Symfony\Component\HttpFoundation\BinaryFileResponse; -use Symfony\Component\HttpFoundation\Cookie; -use Symfony\Component\HttpFoundation\File\UploadedFile; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\StreamedResponse; - -/** - * @author Kévin Dunglas <dunglas@gmail.com> - * @author Antonio J. García Lagar <aj@garcialagar.es> - */ -abstract class AbstractHttpMessageFactoryTest extends TestCase -{ - private $factory; - private $tmpDir; - - abstract protected function buildHttpMessageFactory(): HttpMessageFactoryInterface; - - protected function setUp(): void - { - $this->factory = $this->buildHttpMessageFactory(); - $this->tmpDir = sys_get_temp_dir(); - } - - public function testCreateRequest() - { - $stdClass = new \stdClass(); - $request = new Request( - [ - 'bar' => ['baz' => '42'], - 'foo' => '1', - ], - [ - 'twitter' => [ - '@dunglas' => 'Kévin Dunglas', - '@coopTilleuls' => 'Les-Tilleuls.coop', - ], - 'baz' => '2', - ], - [ - 'a1' => $stdClass, - 'a2' => ['foo' => 'bar'], - ], - [ - 'c1' => 'foo', - 'c2' => ['c3' => 'bar'], - ], - [ - 'f1' => $this->createUploadedFile('F1', 'f1.txt', 'text/plain', \UPLOAD_ERR_OK), - 'foo' => ['f2' => $this->createUploadedFile('F2', 'f2.txt', 'text/plain', \UPLOAD_ERR_OK)], - ], - [ - 'REQUEST_METHOD' => 'POST', - 'HTTP_HOST' => 'dunglas.fr', - 'HTTP_X_SYMFONY' => '2.8', - 'REQUEST_URI' => '/testCreateRequest?bar[baz]=42&foo=1', - 'QUERY_STRING' => 'bar[baz]=42&foo=1', - ], - 'Content' - ); - - $psrRequest = $this->factory->createRequest($request); - - $this->assertEquals('Content', $psrRequest->getBody()->__toString()); - - $queryParams = $psrRequest->getQueryParams(); - $this->assertEquals('1', $queryParams['foo']); - $this->assertEquals('42', $queryParams['bar']['baz']); - - $requestTarget = $psrRequest->getRequestTarget(); - $this->assertEquals('/testCreateRequest?bar[baz]=42&foo=1', urldecode($requestTarget)); - - $parsedBody = $psrRequest->getParsedBody(); - $this->assertEquals('Kévin Dunglas', $parsedBody['twitter']['@dunglas']); - $this->assertEquals('Les-Tilleuls.coop', $parsedBody['twitter']['@coopTilleuls']); - $this->assertEquals('2', $parsedBody['baz']); - - $attributes = $psrRequest->getAttributes(); - $this->assertEquals($stdClass, $attributes['a1']); - $this->assertEquals('bar', $attributes['a2']['foo']); - - $cookies = $psrRequest->getCookieParams(); - $this->assertEquals('foo', $cookies['c1']); - $this->assertEquals('bar', $cookies['c2']['c3']); - - $uploadedFiles = $psrRequest->getUploadedFiles(); - $this->assertEquals('F1', $uploadedFiles['f1']->getStream()->__toString()); - $this->assertEquals('f1.txt', $uploadedFiles['f1']->getClientFilename()); - $this->assertEquals('text/plain', $uploadedFiles['f1']->getClientMediaType()); - $this->assertEquals(\UPLOAD_ERR_OK, $uploadedFiles['f1']->getError()); - - $this->assertEquals('F2', $uploadedFiles['foo']['f2']->getStream()->__toString()); - $this->assertEquals('f2.txt', $uploadedFiles['foo']['f2']->getClientFilename()); - $this->assertEquals('text/plain', $uploadedFiles['foo']['f2']->getClientMediaType()); - $this->assertEquals(\UPLOAD_ERR_OK, $uploadedFiles['foo']['f2']->getError()); - - $serverParams = $psrRequest->getServerParams(); - $this->assertEquals('POST', $serverParams['REQUEST_METHOD']); - $this->assertEquals('2.8', $serverParams['HTTP_X_SYMFONY']); - $this->assertEquals('POST', $psrRequest->getMethod()); - $this->assertEquals(['2.8'], $psrRequest->getHeader('X-Symfony')); - } - - public function testGetContentCanBeCalledAfterRequestCreation() - { - $header = ['HTTP_HOST' => 'dunglas.fr']; - $request = new Request([], [], [], [], [], $header, 'Content'); - - $psrRequest = $this->factory->createRequest($request); - - $this->assertEquals('Content', $psrRequest->getBody()->__toString()); - $this->assertEquals('Content', $request->getContent()); - } - - private function createUploadedFile($content, $originalName, $mimeType, $error) - { - $path = tempnam($this->tmpDir, uniqid()); - file_put_contents($path, $content); - - return new UploadedFile($path, $originalName, $mimeType, $error, true); - } - - public function testCreateResponse() - { - $response = new Response( - 'Response content.', - 202, - ['X-Symfony' => ['3.4']] - ); - $response->headers->setCookie(new Cookie('city', 'Lille', new \DateTime('Wed, 13 Jan 2021 22:23:01 GMT'), '/', null, false, true, false, 'lax')); - - $psrResponse = $this->factory->createResponse($response); - $this->assertEquals('Response content.', $psrResponse->getBody()->__toString()); - $this->assertEquals(202, $psrResponse->getStatusCode()); - $this->assertEquals(['3.4'], $psrResponse->getHeader('X-Symfony')); - - $cookieHeader = $psrResponse->getHeader('Set-Cookie'); - $this->assertIsArray($cookieHeader); - $this->assertCount(1, $cookieHeader); - $this->assertMatchesRegularExpression('{city=Lille; expires=Wed, 13-Jan-2021 22:23:01 GMT;( max-age=\d+;)? path=/; httponly}i', $cookieHeader[0]); - } - - public function testCreateResponseFromStreamed() - { - $response = new StreamedResponse(function () { - echo "Line 1\n"; - flush(); - - echo "Line 2\n"; - flush(); - }); - - $psrResponse = $this->factory->createResponse($response); - - $this->assertEquals("Line 1\nLine 2\n", $psrResponse->getBody()->__toString()); - } - - public function testCreateResponseFromBinaryFile() - { - $path = tempnam($this->tmpDir, uniqid()); - file_put_contents($path, 'Binary'); - - $response = new BinaryFileResponse($path); - - $psrResponse = $this->factory->createResponse($response); - - $this->assertEquals('Binary', $psrResponse->getBody()->__toString()); - } - - public function testCreateResponseFromBinaryFileWithRange() - { - $path = tempnam($this->tmpDir, uniqid()); - file_put_contents($path, 'Binary'); - - $request = new Request(); - $request->headers->set('Range', 'bytes=1-4'); - - $response = new BinaryFileResponse($path, 200, ['Content-Type' => 'plain/text']); - $response->prepare($request); - - $psrResponse = $this->factory->createResponse($response); - - $this->assertEquals('inar', $psrResponse->getBody()->__toString()); - $this->assertSame('bytes 1-4/6', $psrResponse->getHeaderLine('Content-Range')); - } - - public function testUploadErrNoFile() - { - $file = new UploadedFile('', '', null, \UPLOAD_ERR_NO_FILE, true); - - $this->assertEquals(0, $file->getSize()); - $this->assertEquals(\UPLOAD_ERR_NO_FILE, $file->getError()); - $this->assertFalse($file->getSize(), 'SplFile::getSize() returns false on error'); - - $request = new Request( - [], - [], - [], - [], - [ - 'f1' => $file, - 'f2' => ['name' => null, 'type' => null, 'tmp_name' => null, 'error' => \UPLOAD_ERR_NO_FILE, 'size' => 0], - ], - [ - 'REQUEST_METHOD' => 'POST', - 'HTTP_HOST' => 'dunglas.fr', - 'HTTP_X_SYMFONY' => '2.8', - ], - 'Content' - ); - - $psrRequest = $this->factory->createRequest($request); - - $uploadedFiles = $psrRequest->getUploadedFiles(); - - $this->assertEquals(\UPLOAD_ERR_NO_FILE, $uploadedFiles['f1']->getError()); - $this->assertEquals(\UPLOAD_ERR_NO_FILE, $uploadedFiles['f2']->getError()); - } -} diff --git a/vendor/symfony/psr-http-message-bridge/Tests/Factory/HttpFoundationFactoryTest.php b/vendor/symfony/psr-http-message-bridge/Tests/Factory/HttpFoundationFactoryTest.php deleted file mode 100644 index 3a00e2fa7a..0000000000 --- a/vendor/symfony/psr-http-message-bridge/Tests/Factory/HttpFoundationFactoryTest.php +++ /dev/null @@ -1,272 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PsrHttpMessage\Tests\Factory; - -use PHPUnit\Framework\TestCase; -use Psr\Http\Message\UploadedFileInterface; -use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory; -use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Response; -use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\ServerRequest; -use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Stream; -use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\UploadedFile; -use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Uri; -use Symfony\Component\HttpFoundation\Cookie; -use Symfony\Component\HttpFoundation\File\Exception\FileException; -use Symfony\Component\HttpFoundation\File\UploadedFile as HttpFoundationUploadedFile; - -/** - * @author Kévin Dunglas <dunglas@gmail.com> - */ -class HttpFoundationFactoryTest extends TestCase -{ - /** @var HttpFoundationFactory */ - private $factory; - - /** @var string */ - private $tmpDir; - - protected function setUp(): void - { - $this->factory = new HttpFoundationFactory(); - $this->tmpDir = sys_get_temp_dir(); - } - - public function testCreateRequest() - { - $stdClass = new \stdClass(); - $serverRequest = new ServerRequest( - '1.1', - [ - 'X-Dunglas-API-Platform' => '1.0', - 'X-data' => ['a', 'b'], - ], - new Stream('The body'), - '/about/kevin', - 'GET', - 'http://les-tilleuls.coop/about/kevin', - ['country' => 'France'], - ['city' => 'Lille'], - ['url' => 'http://les-tilleuls.coop'], - [ - 'doc1' => $this->createUploadedFile('Doc 1', \UPLOAD_ERR_OK, 'doc1.txt', 'text/plain'), - 'nested' => [ - 'docs' => [ - $this->createUploadedFile('Doc 2', \UPLOAD_ERR_OK, 'doc2.txt', 'text/plain'), - $this->createUploadedFile('Doc 3', \UPLOAD_ERR_OK, 'doc3.txt', 'text/plain'), - ], - ], - ], - ['url' => 'http://dunglas.fr'], - ['custom' => $stdClass] - ); - - $symfonyRequest = $this->factory->createRequest($serverRequest); - $files = $symfonyRequest->files->all(); - - $this->assertEquals('http://les-tilleuls.coop', $symfonyRequest->query->get('url')); - $this->assertEquals('doc1.txt', $files['doc1']->getClientOriginalName()); - $this->assertEquals('doc2.txt', $files['nested']['docs'][0]->getClientOriginalName()); - $this->assertEquals('doc3.txt', $files['nested']['docs'][1]->getClientOriginalName()); - $this->assertEquals('http://dunglas.fr', $symfonyRequest->request->get('url')); - $this->assertEquals($stdClass, $symfonyRequest->attributes->get('custom')); - $this->assertEquals('Lille', $symfonyRequest->cookies->get('city')); - $this->assertEquals('France', $symfonyRequest->server->get('country')); - $this->assertEquals('The body', $symfonyRequest->getContent()); - $this->assertEquals('1.0', $symfonyRequest->headers->get('X-Dunglas-API-Platform')); - $this->assertEquals(['a', 'b'], $symfonyRequest->headers->all('X-data')); - } - - public function testCreateRequestWithStreamedBody() - { - $serverRequest = new ServerRequest( - '1.1', - [], - new Stream('The body'), - '/', - 'GET', - null, - [], - [], - [], - [], - null, - [] - ); - - $symfonyRequest = $this->factory->createRequest($serverRequest, true); - $this->assertEquals('The body', $symfonyRequest->getContent()); - } - - public function testCreateRequestWithNullParsedBody() - { - $serverRequest = new ServerRequest( - '1.1', - [], - new Stream(), - '/', - 'GET', - null, - [], - [], - [], - [], - null, - [] - ); - - $this->assertCount(0, $this->factory->createRequest($serverRequest)->request); - } - - public function testCreateRequestWithObjectParsedBody() - { - $serverRequest = new ServerRequest( - '1.1', - [], - new Stream(), - '/', - 'GET', - null, - [], - [], - [], - [], - new \stdClass(), - [] - ); - - $this->assertCount(0, $this->factory->createRequest($serverRequest)->request); - } - - public function testCreateRequestWithUri() - { - $serverRequest = new ServerRequest( - '1.1', - [], - new Stream(), - '/', - 'GET', - new Uri('http://les-tilleuls.coop/about/kevin'), - [], - [], - [], - [], - null, - [] - ); - - $this->assertEquals('/about/kevin', $this->factory->createRequest($serverRequest)->getPathInfo()); - } - - public function testCreateUploadedFile() - { - $uploadedFile = $this->createUploadedFile('An uploaded file.', \UPLOAD_ERR_OK, 'myfile.txt', 'text/plain'); - $symfonyUploadedFile = $this->callCreateUploadedFile($uploadedFile); - $size = $symfonyUploadedFile->getSize(); - - $uniqid = uniqid(); - $symfonyUploadedFile->move($this->tmpDir, $uniqid); - - $this->assertEquals($uploadedFile->getSize(), $size); - $this->assertEquals(\UPLOAD_ERR_OK, $symfonyUploadedFile->getError()); - $this->assertEquals('myfile.txt', $symfonyUploadedFile->getClientOriginalName()); - $this->assertEquals('txt', $symfonyUploadedFile->getClientOriginalExtension()); - $this->assertEquals('text/plain', $symfonyUploadedFile->getClientMimeType()); - $this->assertEquals('An uploaded file.', file_get_contents($this->tmpDir.'/'.$uniqid)); - } - - public function testCreateUploadedFileWithError() - { - $this->expectException(FileException::class); - $this->expectExceptionMessage('The file "e" could not be written on disk.'); - - $uploadedFile = $this->createUploadedFile('Error.', \UPLOAD_ERR_CANT_WRITE, 'e', 'text/plain'); - $symfonyUploadedFile = $this->callCreateUploadedFile($uploadedFile); - - $this->assertEquals(\UPLOAD_ERR_CANT_WRITE, $symfonyUploadedFile->getError()); - - $symfonyUploadedFile->move($this->tmpDir, 'shouldFail.txt'); - } - - private function createUploadedFile($content, $error, $clientFileName, $clientMediaType): UploadedFile - { - $filePath = tempnam($this->tmpDir, uniqid()); - file_put_contents($filePath, $content); - - return new UploadedFile($filePath, filesize($filePath), $error, $clientFileName, $clientMediaType); - } - - private function callCreateUploadedFile(UploadedFileInterface $uploadedFile): HttpFoundationUploadedFile - { - $reflection = new \ReflectionClass($this->factory); - $createUploadedFile = $reflection->getMethod('createUploadedFile'); - $createUploadedFile->setAccessible(true); - - return $createUploadedFile->invokeArgs($this->factory, [$uploadedFile]); - } - - public function testCreateResponse() - { - $response = new Response( - '1.0', - [ - 'X-Symfony' => ['2.8'], - 'Set-Cookie' => [ - 'theme=light', - 'test', - 'ABC=AeD; Domain=dunglas.fr; Path=/kevin; Expires=Wed, 13 Jan 2021 22:23:01 GMT; Secure; HttpOnly; SameSite=Strict', - ], - ], - new Stream('The response body'), - 200 - ); - - $symfonyResponse = $this->factory->createResponse($response); - - $this->assertEquals('1.0', $symfonyResponse->getProtocolVersion()); - $this->assertEquals('2.8', $symfonyResponse->headers->get('X-Symfony')); - - $cookies = $symfonyResponse->headers->getCookies(); - $this->assertEquals('theme', $cookies[0]->getName()); - $this->assertEquals('light', $cookies[0]->getValue()); - $this->assertEquals(0, $cookies[0]->getExpiresTime()); - $this->assertNull($cookies[0]->getDomain()); - $this->assertEquals('/', $cookies[0]->getPath()); - $this->assertFalse($cookies[0]->isSecure()); - $this->assertFalse($cookies[0]->isHttpOnly()); - - $this->assertEquals('test', $cookies[1]->getName()); - $this->assertNull($cookies[1]->getValue()); - - $this->assertEquals('ABC', $cookies[2]->getName()); - $this->assertEquals('AeD', $cookies[2]->getValue()); - $this->assertEquals(strtotime('Wed, 13 Jan 2021 22:23:01 GMT'), $cookies[2]->getExpiresTime()); - $this->assertEquals('dunglas.fr', $cookies[2]->getDomain()); - $this->assertEquals('/kevin', $cookies[2]->getPath()); - $this->assertTrue($cookies[2]->isSecure()); - $this->assertTrue($cookies[2]->isHttpOnly()); - if (\defined('Symfony\Component\HttpFoundation\Cookie::SAMESITE_STRICT')) { - $this->assertEquals(Cookie::SAMESITE_STRICT, $cookies[2]->getSameSite()); - } - - $this->assertEquals('The response body', $symfonyResponse->getContent()); - $this->assertEquals(200, $symfonyResponse->getStatusCode()); - - $symfonyResponse = $this->factory->createResponse($response, true); - - ob_start(); - $symfonyResponse->sendContent(); - $sentContent = ob_get_clean(); - - $this->assertEquals('The response body', $sentContent); - $this->assertEquals(200, $symfonyResponse->getStatusCode()); - } -} diff --git a/vendor/symfony/psr-http-message-bridge/Tests/Factory/PsrHttpFactoryTest.php b/vendor/symfony/psr-http-message-bridge/Tests/Factory/PsrHttpFactoryTest.php deleted file mode 100644 index b47cefc18d..0000000000 --- a/vendor/symfony/psr-http-message-bridge/Tests/Factory/PsrHttpFactoryTest.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PsrHttpMessage\Tests\Factory; - -use Nyholm\Psr7\Factory\Psr17Factory; -use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory; -use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface; - -/** - * @author Kévin Dunglas <dunglas@gmail.com> - * @author Antonio J. García Lagar <aj@garcialagar.es> - */ -class PsrHttpFactoryTest extends AbstractHttpMessageFactoryTest -{ - protected function buildHttpMessageFactory(): HttpMessageFactoryInterface - { - $factory = new Psr17Factory(); - - return new PsrHttpFactory($factory, $factory, $factory, $factory); - } -} diff --git a/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/App/Controller/PsrRequestController.php b/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/App/Controller/PsrRequestController.php deleted file mode 100644 index 18b774189a..0000000000 --- a/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/App/Controller/PsrRequestController.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php - -namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\App\Controller; - -use Psr\Http\Message\MessageInterface; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseFactoryInterface; -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; -use Psr\Http\Message\StreamFactoryInterface; - -final class PsrRequestController -{ - private $responseFactory; - private $streamFactory; - - public function __construct(ResponseFactoryInterface $responseFactory, StreamFactoryInterface $streamFactory) - { - $this->responseFactory = $responseFactory; - $this->streamFactory = $streamFactory; - } - - public function serverRequestAction(ServerRequestInterface $request): ResponseInterface - { - return $this->responseFactory - ->createResponse() - ->withBody($this->streamFactory->createStream(sprintf('<html><body>%s</body></html>', $request->getMethod()))); - } - - public function requestAction(RequestInterface $request): ResponseInterface - { - return $this->responseFactory - ->createResponse() - ->withStatus(403) - ->withBody($this->streamFactory->createStream(sprintf('<html><body>%s %s</body></html>', $request->getMethod(), $request->getBody()->getContents()))); - } - - public function messageAction(MessageInterface $request): ResponseInterface - { - return $this->responseFactory - ->createResponse() - ->withStatus(422) - ->withBody($this->streamFactory->createStream(sprintf('<html><body>%s</body></html>', $request->getHeader('X-My-Header')[0]))); - } -} diff --git a/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/App/Kernel.php b/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/App/Kernel.php deleted file mode 100644 index aef819342a..0000000000 --- a/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/App/Kernel.php +++ /dev/null @@ -1,76 +0,0 @@ -<?php - -namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\App; - -use Nyholm\Psr7\Factory\Psr17Factory; -use Psr\Http\Message\ResponseFactoryInterface; -use Psr\Http\Message\ServerRequestFactoryInterface; -use Psr\Http\Message\StreamFactoryInterface; -use Psr\Http\Message\UploadedFileFactoryInterface; -use Psr\Log\NullLogger; -use Symfony\Bridge\PsrHttpMessage\ArgumentValueResolver\PsrServerRequestResolver; -use Symfony\Bridge\PsrHttpMessage\EventListener\PsrResponseListener; -use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory; -use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory; -use Symfony\Bridge\PsrHttpMessage\HttpFoundationFactoryInterface; -use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface; -use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\App\Controller\PsrRequestController; -use Symfony\Bundle\FrameworkBundle\FrameworkBundle; -use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symfony\Component\HttpKernel\Kernel as SymfonyKernel; -use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; - -class Kernel extends SymfonyKernel -{ - use MicroKernelTrait; - - public function registerBundles(): iterable - { - yield new FrameworkBundle(); - } - - public function getProjectDir(): string - { - return __DIR__; - } - - protected function configureRoutes(RoutingConfigurator $routes): void - { - $routes - ->add('server_request', '/server-request')->controller([PsrRequestController::class, 'serverRequestAction'])->methods(['GET']) - ->add('request', '/request')->controller([PsrRequestController::class, 'requestAction'])->methods(['POST']) - ->add('message', '/message')->controller([PsrRequestController::class, 'messageAction'])->methods(['PUT']) - ; - } - - protected function configureContainer(ContainerConfigurator $container): void - { - $container->extension('framework', [ - 'router' => ['utf8' => true], - 'secret' => 'for your eyes only', - 'test' => true, - ]); - - $container->services() - ->set('nyholm.psr_factory', Psr17Factory::class) - ->alias(ResponseFactoryInterface::class, 'nyholm.psr_factory') - ->alias(ServerRequestFactoryInterface::class, 'nyholm.psr_factory') - ->alias(StreamFactoryInterface::class, 'nyholm.psr_factory') - ->alias(UploadedFileFactoryInterface::class, 'nyholm.psr_factory') - ; - - $container->services() - ->defaults()->autowire()->autoconfigure() - ->set(HttpFoundationFactoryInterface::class, HttpFoundationFactory::class) - ->set(HttpMessageFactoryInterface::class, PsrHttpFactory::class) - ->set(PsrResponseListener::class) - ->set(PsrServerRequestResolver::class) - ; - - $container->services() - ->set('logger', NullLogger::class) - ->set(PsrRequestController::class)->public()->autowire() - ; - } -} diff --git a/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/App/Kernel44.php b/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/App/Kernel44.php deleted file mode 100644 index e976ae2686..0000000000 --- a/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/App/Kernel44.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php - -namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\App; - -use Nyholm\Psr7\Factory\Psr17Factory; -use Psr\Http\Message\ResponseFactoryInterface; -use Psr\Http\Message\ServerRequestFactoryInterface; -use Psr\Http\Message\StreamFactoryInterface; -use Psr\Http\Message\UploadedFileFactoryInterface; -use Psr\Log\NullLogger; -use Symfony\Bridge\PsrHttpMessage\ArgumentValueResolver\PsrServerRequestResolver; -use Symfony\Bridge\PsrHttpMessage\EventListener\PsrResponseListener; -use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory; -use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory; -use Symfony\Bridge\PsrHttpMessage\HttpFoundationFactoryInterface; -use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface; -use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\App\Controller\PsrRequestController; -use Symfony\Bundle\FrameworkBundle\FrameworkBundle; -use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\HttpKernel\Kernel as SymfonyKernel; -use Symfony\Component\Routing\RouteCollectionBuilder; - -class Kernel44 extends SymfonyKernel -{ - use MicroKernelTrait; - - public function registerBundles(): iterable - { - yield new FrameworkBundle(); - } - - public function getProjectDir(): string - { - return __DIR__; - } - - protected function configureRoutes(RouteCollectionBuilder $routes): void - { - $routes->add('/server-request', PsrRequestController::class.'::serverRequestAction')->setMethods(['GET']); - $routes->add('/request', PsrRequestController::class.'::requestAction')->setMethods(['POST']); - $routes->add('/message', PsrRequestController::class.'::messageAction')->setMethods(['PUT']); - } - - protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void - { - $container->loadFromExtension('framework', [ - 'secret' => 'for your eyes only', - 'test' => true, - ]); - - $container->register('nyholm.psr_factory', Psr17Factory::class); - $container->setAlias(ResponseFactoryInterface::class, 'nyholm.psr_factory'); - $container->setAlias(ServerRequestFactoryInterface::class, 'nyholm.psr_factory'); - $container->setAlias(StreamFactoryInterface::class, 'nyholm.psr_factory'); - $container->setAlias(UploadedFileFactoryInterface::class, 'nyholm.psr_factory'); - - $container->register(HttpFoundationFactoryInterface::class, HttpFoundationFactory::class)->setAutowired(true)->setAutoconfigured(true); - $container->register(HttpMessageFactoryInterface::class, PsrHttpFactory::class)->setAutowired(true)->setAutoconfigured(true); - $container->register(PsrResponseListener::class)->setAutowired(true)->setAutoconfigured(true); - $container->register(PsrServerRequestResolver::class)->setAutowired(true)->setAutoconfigured(true); - - $container->register('logger', NullLogger::class); - $container->register(PsrRequestController::class)->setPublic(true)->setAutowired(true); - } -} diff --git a/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Message.php b/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Message.php deleted file mode 100644 index d561086b96..0000000000 --- a/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Message.php +++ /dev/null @@ -1,118 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures; - -use Psr\Http\Message\MessageInterface; -use Psr\Http\Message\StreamInterface; - -/** - * Message. - * - * @author Kévin Dunglas <dunglas@gmail.com> - */ -class Message implements MessageInterface -{ - private $version = '1.1'; - private $headers = []; - private $body; - - public function __construct($version = '1.1', array $headers = [], StreamInterface $body = null) - { - $this->version = $version; - $this->headers = $headers; - $this->body = $body ?? new Stream(); - } - - public function getProtocolVersion(): string - { - return $this->version; - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withProtocolVersion($version) - { - throw new \BadMethodCallException('Not implemented.'); - } - - public function getHeaders(): array - { - return $this->headers; - } - - public function hasHeader($name): bool - { - return isset($this->headers[$name]); - } - - public function getHeader($name): array - { - return $this->hasHeader($name) ? $this->headers[$name] : []; - } - - public function getHeaderLine($name): string - { - return $this->hasHeader($name) ? implode(',', $this->headers[$name]) : ''; - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withHeader($name, $value) - { - $this->headers[$name] = (array) $value; - - return $this; - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withAddedHeader($name, $value) - { - throw new \BadMethodCallException('Not implemented.'); - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withoutHeader($name) - { - unset($this->headers[$name]); - - return $this; - } - - public function getBody(): StreamInterface - { - return $this->body; - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withBody(StreamInterface $body) - { - throw new \BadMethodCallException('Not implemented.'); - } -} diff --git a/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Response.php b/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Response.php deleted file mode 100644 index 0bcf7f4063..0000000000 --- a/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Response.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures; - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\StreamInterface; - -/** - * @author Kévin Dunglas <dunglas@gmail.com> - */ -class Response extends Message implements ResponseInterface -{ - private $statusCode; - - public function __construct($version = '1.1', array $headers = [], StreamInterface $body = null, $statusCode = 200) - { - parent::__construct($version, $headers, $body); - - $this->statusCode = $statusCode; - } - - public function getStatusCode(): int - { - return $this->statusCode; - } - - /** - * @return static - */ - public function withStatus($code, $reasonPhrase = '') - { - throw new \BadMethodCallException('Not implemented.'); - } - - public function getReasonPhrase(): string - { - throw new \BadMethodCallException('Not implemented.'); - } -} diff --git a/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/ServerRequest.php b/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/ServerRequest.php deleted file mode 100644 index b8df06a90f..0000000000 --- a/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/ServerRequest.php +++ /dev/null @@ -1,202 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures; - -use Psr\Http\Message\ServerRequestInterface; -use Psr\Http\Message\StreamInterface; -use Psr\Http\Message\UriInterface; - -/** - * @author Kévin Dunglas <dunglas@gmail.com> - */ -class ServerRequest extends Message implements ServerRequestInterface -{ - private $requestTarget; - private $method; - private $uri; - private $server; - private $cookies; - private $query; - private $uploadedFiles; - private $data; - private $attributes; - - public function __construct($version = '1.1', array $headers = [], StreamInterface $body = null, $requestTarget = '/', $method = 'GET', $uri = null, array $server = [], array $cookies = [], array $query = [], array $uploadedFiles = [], $data = null, array $attributes = []) - { - parent::__construct($version, $headers, $body); - - $this->requestTarget = $requestTarget; - $this->method = $method; - $this->uri = $uri; - $this->server = $server; - $this->cookies = $cookies; - $this->query = $query; - $this->uploadedFiles = $uploadedFiles; - $this->data = $data; - $this->attributes = $attributes; - } - - public function getRequestTarget(): string - { - return $this->requestTarget; - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withRequestTarget($requestTarget) - { - throw new \BadMethodCallException('Not implemented.'); - } - - public function getMethod(): string - { - return $this->method; - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withMethod($method) - { - throw new \BadMethodCallException('Not implemented.'); - } - - /** - * {@inheritdoc} - * - * @return UriInterface - */ - public function getUri() - { - return $this->uri; - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withUri(UriInterface $uri, $preserveHost = false) - { - throw new \BadMethodCallException('Not implemented.'); - } - - public function getServerParams(): array - { - return $this->server; - } - - public function getCookieParams(): array - { - return $this->cookies; - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withCookieParams(array $cookies) - { - throw new \BadMethodCallException('Not implemented.'); - } - - public function getQueryParams(): array - { - return $this->query; - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withQueryParams(array $query) - { - throw new \BadMethodCallException('Not implemented.'); - } - - public function getUploadedFiles(): array - { - return $this->uploadedFiles; - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withUploadedFiles(array $uploadedFiles) - { - throw new \BadMethodCallException('Not implemented.'); - } - - /** - * {@inheritdoc} - * - * @return array|object|null - */ - public function getParsedBody() - { - return $this->data; - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withParsedBody($data) - { - throw new \BadMethodCallException('Not implemented.'); - } - - public function getAttributes(): array - { - return $this->attributes; - } - - /** - * {@inheritdoc} - * - * @return mixed - */ - public function getAttribute($name, $default = null) - { - return $this->attributes[$name] ?? $default; - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withAttribute($name, $value) - { - throw new \BadMethodCallException('Not implemented.'); - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withoutAttribute($name) - { - throw new \BadMethodCallException('Not implemented.'); - } -} diff --git a/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Stream.php b/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Stream.php deleted file mode 100644 index f664bae62f..0000000000 --- a/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Stream.php +++ /dev/null @@ -1,108 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures; - -use Psr\Http\Message\StreamInterface; - -/** - * @author Kévin Dunglas <dunglas@gmail.com> - */ -class Stream implements StreamInterface -{ - private $stringContent; - private $eof = true; - - public function __construct($stringContent = '') - { - $this->stringContent = $stringContent; - } - - public function __toString(): string - { - return $this->stringContent; - } - - public function close(): void - { - } - - public function detach() - { - return fopen('data://text/plain,'.$this->stringContent, 'r'); - } - - public function getSize(): ?int - { - return null; - } - - public function tell(): int - { - return 0; - } - - public function eof(): bool - { - return $this->eof; - } - - public function isSeekable(): bool - { - return true; - } - - public function seek($offset, $whence = \SEEK_SET): void - { - } - - public function rewind(): void - { - $this->eof = false; - } - - public function isWritable(): bool - { - return false; - } - - public function write($string): int - { - return \strlen($string); - } - - public function isReadable(): bool - { - return true; - } - - public function read($length): string - { - $this->eof = true; - - return $this->stringContent; - } - - public function getContents(): string - { - return $this->stringContent; - } - - /** - * {@inheritdoc} - * - * @return mixed - */ - public function getMetadata($key = null) - { - return null; - } -} diff --git a/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/UploadedFile.php b/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/UploadedFile.php deleted file mode 100644 index 900400853b..0000000000 --- a/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/UploadedFile.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures; - -use Psr\Http\Message\UploadedFileInterface; - -/** - * @author Kévin Dunglas <dunglas@gmail.com> - */ -class UploadedFile implements UploadedFileInterface -{ - private $filePath; - private $size; - private $error; - private $clientFileName; - private $clientMediaType; - - public function __construct($filePath, $size = null, $error = \UPLOAD_ERR_OK, $clientFileName = null, $clientMediaType = null) - { - $this->filePath = $filePath; - $this->size = $size; - $this->error = $error; - $this->clientFileName = $clientFileName; - $this->clientMediaType = $clientMediaType; - } - - public function getStream(): Stream - { - return new Stream(file_get_contents($this->filePath)); - } - - public function moveTo($targetPath): void - { - rename($this->filePath, $targetPath); - } - - public function getSize(): ?int - { - return $this->size; - } - - public function getError(): int - { - return $this->error; - } - - public function getClientFilename(): ?string - { - return $this->clientFileName; - } - - public function getClientMediaType(): ?string - { - return $this->clientMediaType; - } -} diff --git a/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Uri.php b/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Uri.php deleted file mode 100644 index 48f513d39a..0000000000 --- a/vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Uri.php +++ /dev/null @@ -1,170 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures; - -use Psr\Http\Message\UriInterface; - -/** - * @author Rougin Royce Gutib <rougingutib@gmail.com> - */ -class Uri implements UriInterface -{ - private $scheme = ''; - private $userInfo = ''; - private $host = ''; - private $port; - private $path = ''; - private $query = ''; - private $fragment = ''; - private $uriString; - - public function __construct(string $uri = '') - { - $parts = parse_url($uri); - - $this->scheme = $parts['scheme'] ?? ''; - $this->userInfo = $parts['user'] ?? ''; - $this->host = $parts['host'] ?? ''; - $this->port = $parts['port'] ?? null; - $this->path = $parts['path'] ?? ''; - $this->query = $parts['query'] ?? ''; - $this->fragment = $parts['fragment'] ?? ''; - $this->uriString = $uri; - } - - public function getScheme(): string - { - return $this->scheme; - } - - public function getAuthority(): string - { - if (empty($this->host)) { - return ''; - } - - $authority = $this->host; - - if (!empty($this->userInfo)) { - $authority = $this->userInfo.'@'.$authority; - } - - $authority .= ':'.$this->port; - - return $authority; - } - - public function getUserInfo(): string - { - return $this->userInfo; - } - - public function getHost(): string - { - return $this->host; - } - - public function getPort(): ?int - { - return $this->port; - } - - public function getPath(): string - { - return $this->path; - } - - public function getQuery(): string - { - return $this->query; - } - - public function getFragment(): string - { - return $this->fragment; - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withScheme($scheme) - { - throw new \BadMethodCallException('Not implemented.'); - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withUserInfo($user, $password = null) - { - throw new \BadMethodCallException('Not implemented.'); - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withHost($host) - { - throw new \BadMethodCallException('Not implemented.'); - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withPort($port) - { - throw new \BadMethodCallException('Not implemented.'); - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withPath($path) - { - throw new \BadMethodCallException('Not implemented.'); - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withQuery($query) - { - throw new \BadMethodCallException('Not implemented.'); - } - - /** - * {@inheritdoc} - * - * @return static - */ - public function withFragment($fragment) - { - throw new \BadMethodCallException('Not implemented.'); - } - - public function __toString(): string - { - return $this->uriString; - } -} diff --git a/vendor/symfony/psr-http-message-bridge/Tests/Functional/ControllerTest.php b/vendor/symfony/psr-http-message-bridge/Tests/Functional/ControllerTest.php deleted file mode 100644 index 0b88405b55..0000000000 --- a/vendor/symfony/psr-http-message-bridge/Tests/Functional/ControllerTest.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PsrHttpMessage\Tests\Functional; - -use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\App\Kernel; -use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\App\Kernel44; -use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -use Symfony\Component\HttpKernel\Kernel as SymfonyKernel; - -/** - * @author Alexander M. Turek <me@derrabus.de> - */ -final class ControllerTest extends WebTestCase -{ - public function testServerRequestAction() - { - $client = self::createClient(); - $crawler = $client->request('GET', '/server-request'); - - self::assertResponseStatusCodeSame(200); - self::assertSame('GET', $crawler->text()); - } - - public function testRequestAction() - { - $client = self::createClient(); - $crawler = $client->request('POST', '/request', [], [], [], 'some content'); - - self::assertResponseStatusCodeSame(403); - self::assertSame('POST some content', $crawler->text()); - } - - public function testMessageAction() - { - $client = self::createClient(); - $crawler = $client->request('PUT', '/message', [], [], ['HTTP_X_MY_HEADER' => 'some content']); - - self::assertResponseStatusCodeSame(422); - self::assertSame('some content', $crawler->text()); - } - - protected static function getKernelClass(): string - { - return SymfonyKernel::VERSION_ID >= 50200 ? Kernel::class : Kernel44::class; - } -} diff --git a/vendor/symfony/psr-http-message-bridge/Tests/Functional/CovertTest.php b/vendor/symfony/psr-http-message-bridge/Tests/Functional/CovertTest.php deleted file mode 100644 index 3d72b71731..0000000000 --- a/vendor/symfony/psr-http-message-bridge/Tests/Functional/CovertTest.php +++ /dev/null @@ -1,237 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PsrHttpMessage\Tests\Functional; - -use Nyholm\Psr7\Factory\Psr17Factory; -use Nyholm\Psr7\Response as Psr7Response; -use Nyholm\Psr7\ServerRequest as Psr7Request; -use Nyholm\Psr7\Stream as Psr7Stream; -use PHPUnit\Framework\TestCase; -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; -use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory; -use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory; -use Symfony\Bridge\PsrHttpMessage\HttpFoundationFactoryInterface; -use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface; -use Symfony\Component\HttpFoundation\Cookie; -use Symfony\Component\HttpFoundation\File\UploadedFile; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Test to convert a request/response back and forth to make sure we do not loose data. - * - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -class CovertTest extends TestCase -{ - protected function setUp(): void - { - if (!class_exists(Psr7Request::class)) { - $this->markTestSkipped('nyholm/psr7 is not installed.'); - } - } - - /** - * @dataProvider requestProvider - * - * @param Request|ServerRequestInterface $request - * @param HttpFoundationFactoryInterface|HttpMessageFactoryInterface $firstFactory - * @param HttpFoundationFactoryInterface|HttpMessageFactoryInterface $secondFactory - */ - public function testConvertRequestMultipleTimes($request, $firstFactory, $secondFactory) - { - $temporaryRequest = $firstFactory->createRequest($request); - $finalRequest = $secondFactory->createRequest($temporaryRequest); - - if ($finalRequest instanceof Request) { - $this->assertEquals($request->getBasePath(), $finalRequest->getBasePath()); - $this->assertEquals($request->getBaseUrl(), $finalRequest->getBaseUrl()); - $this->assertEquals($request->getContent(), $finalRequest->getContent()); - $this->assertEquals($request->getEncodings(), $finalRequest->getEncodings()); - $this->assertEquals($request->getETags(), $finalRequest->getETags()); - $this->assertEquals($request->getHost(), $finalRequest->getHost()); - $this->assertEquals($request->getHttpHost(), $finalRequest->getHttpHost()); - $this->assertEquals($request->getMethod(), $finalRequest->getMethod()); - $this->assertEquals($request->getPassword(), $finalRequest->getPassword()); - $this->assertEquals($request->getPathInfo(), $finalRequest->getPathInfo()); - $this->assertEquals($request->getPort(), $finalRequest->getPort()); - $this->assertEquals($request->getProtocolVersion(), $finalRequest->getProtocolVersion()); - $this->assertEquals($request->getQueryString(), $finalRequest->getQueryString()); - $this->assertEquals($request->getRequestUri(), $finalRequest->getRequestUri()); - $this->assertEquals($request->getScheme(), $finalRequest->getScheme()); - $this->assertEquals($request->getSchemeAndHttpHost(), $finalRequest->getSchemeAndHttpHost()); - $this->assertEquals($request->getScriptName(), $finalRequest->getScriptName()); - $this->assertEquals($request->getUri(), $finalRequest->getUri()); - $this->assertEquals($request->getUser(), $finalRequest->getUser()); - $this->assertEquals($request->getUserInfo(), $finalRequest->getUserInfo()); - } elseif ($finalRequest instanceof ServerRequestInterface) { - $strToLower = function ($arr) { - foreach ($arr as $key => $value) { - yield strtolower($key) => $value; - } - }; - $this->assertEquals($request->getAttributes(), $finalRequest->getAttributes()); - $this->assertEquals($request->getCookieParams(), $finalRequest->getCookieParams()); - $this->assertEquals((array) $request->getParsedBody(), (array) $finalRequest->getParsedBody()); - $this->assertEquals($request->getQueryParams(), $finalRequest->getQueryParams()); - // PSR7 does not define a "withServerParams" so this is impossible to implement without knowing the PSR7 implementation. - //$this->assertEquals($request->getServerParams(), $finalRequest->getServerParams()); - $this->assertEquals($request->getUploadedFiles(), $finalRequest->getUploadedFiles()); - $this->assertEquals($request->getMethod(), $finalRequest->getMethod()); - $this->assertEquals($request->getRequestTarget(), $finalRequest->getRequestTarget()); - $this->assertEquals((string) $request->getUri(), (string) $finalRequest->getUri()); - $this->assertEquals((string) $request->getBody(), (string) $finalRequest->getBody()); - $this->assertEquals($strToLower($request->getHeaders()), $strToLower($finalRequest->getHeaders())); - $this->assertEquals($request->getProtocolVersion(), $finalRequest->getProtocolVersion()); - } else { - $this->fail('$finalRequest must be an instance of PSR7 or a HTTPFoundation request'); - } - } - - public function requestProvider() - { - $sfRequest = new Request( - [ - 'foo' => '1', - 'bar' => ['baz' => '42'], - ], - [ - 'twitter' => [ - '@dunglas' => 'Kévin Dunglas', - '@coopTilleuls' => 'Les-Tilleuls.coop', - ], - 'baz' => '2', - ], - [ - 'a2' => ['foo' => 'bar'], - ], - [ - 'c1' => 'foo', - 'c2' => ['c3' => 'bar'], - ], - [ - 'f1' => $this->createUploadedFile('F1', 'f1.txt', 'text/plain', \UPLOAD_ERR_OK), - 'foo' => ['f2' => $this->createUploadedFile('F2', 'f2.txt', 'text/plain', \UPLOAD_ERR_OK)], - ], - [ - 'REQUEST_METHOD' => 'POST', - 'HTTP_HOST' => 'dunglas.fr', - 'SERVER_NAME' => 'dunglas.fr', - 'SERVER_PORT' => null, - 'HTTP_X_SYMFONY' => '2.8', - 'REQUEST_URI' => '/testCreateRequest?foo=1&bar%5Bbaz%5D=42', - 'QUERY_STRING' => 'foo=1&bar%5Bbaz%5D=42', - ], - 'Content' - ); - - $psr7Requests = [ - (new Psr7Request('POST', 'http://tnyholm.se/foo/?bar=biz')) - ->withQueryParams(['bar' => 'biz']), - new Psr7Request('GET', 'https://hey-octave.com/'), - new Psr7Request('GET', 'https://hey-octave.com:443/'), - new Psr7Request('GET', 'https://hey-octave.com:4242/'), - new Psr7Request('GET', 'http://hey-octave.com:80/'), - ]; - - $nyholmFactory = new Psr17Factory(); - $psr17Factory = new PsrHttpFactory($nyholmFactory, $nyholmFactory, $nyholmFactory, $nyholmFactory); - $symfonyFactory = new HttpFoundationFactory(); - - return array_merge([ - [$sfRequest, $psr17Factory, $symfonyFactory], - ], array_map(function ($psr7Request) use ($symfonyFactory, $psr17Factory) { - return [$psr7Request, $symfonyFactory, $psr17Factory]; - }, $psr7Requests)); - } - - /** - * @dataProvider responseProvider - * - * @param Response|ResponseInterface $response - * @param HttpFoundationFactoryInterface|HttpMessageFactoryInterface $firstFactory - * @param HttpFoundationFactoryInterface|HttpMessageFactoryInterface $secondFactory - */ - public function testConvertResponseMultipleTimes($response, $firstFactory, $secondFactory) - { - $temporaryResponse = $firstFactory->createResponse($response); - $finalResponse = $secondFactory->createResponse($temporaryResponse); - - if ($finalResponse instanceof Response) { - $this->assertEquals($response->getAge(), $finalResponse->getAge()); - $this->assertEquals($response->getCharset(), $finalResponse->getCharset()); - $this->assertEquals($response->getContent(), $finalResponse->getContent()); - $this->assertEquals($response->getDate(), $finalResponse->getDate()); - $this->assertEquals($response->getEtag(), $finalResponse->getEtag()); - $this->assertEquals($response->getExpires(), $finalResponse->getExpires()); - $this->assertEquals($response->getLastModified(), $finalResponse->getLastModified()); - $this->assertEquals($response->getMaxAge(), $finalResponse->getMaxAge()); - $this->assertEquals($response->getProtocolVersion(), $finalResponse->getProtocolVersion()); - $this->assertEquals($response->getStatusCode(), $finalResponse->getStatusCode()); - $this->assertEquals($response->getTtl(), $finalResponse->getTtl()); - } elseif ($finalResponse instanceof ResponseInterface) { - $strToLower = function ($arr) { - foreach ($arr as $key => $value) { - yield strtolower($key) => $value; - } - }; - $this->assertEquals($response->getStatusCode(), $finalResponse->getStatusCode()); - $this->assertEquals($response->getReasonPhrase(), $finalResponse->getReasonPhrase()); - $this->assertEquals((string) $response->getBody(), (string) $finalResponse->getBody()); - $this->assertEquals($strToLower($response->getHeaders()), $strToLower($finalResponse->getHeaders())); - $this->assertEquals($response->getProtocolVersion(), $finalResponse->getProtocolVersion()); - } else { - $this->fail('$finalResponse must be an instance of PSR7 or a HTTPFoundation response'); - } - } - - public function responseProvider() - { - $sfResponse = new Response( - 'Response content.', - 202, - ['x-symfony' => ['3.4']] - ); - - if (method_exists(Cookie::class, 'create')) { - $cookie = Cookie::create('city', 'Lille', new \DateTime('Wed, 13 Jan 2021 22:23:01 GMT')); - } else { - $cookie = new Cookie('city', 'Lille', new \DateTime('Wed, 13 Jan 2021 22:23:01 GMT')); - } - - $sfResponse->headers->setCookie($cookie); - $body = Psr7Stream::create(); - $status = 302; - $headers = [ - 'location' => ['http://example.com/'], - ]; - $zendResponse = new Psr7Response($status, $headers, $body); - - $nyholmFactory = new Psr17Factory(); - $psr17Factory = new PsrHttpFactory($nyholmFactory, $nyholmFactory, $nyholmFactory, $nyholmFactory); - $symfonyFactory = new HttpFoundationFactory(); - - return [ - [$sfResponse, $psr17Factory, $symfonyFactory], - [$zendResponse, $symfonyFactory, $psr17Factory], - ]; - } - - private function createUploadedFile($content, $originalName, $mimeType, $error) - { - $path = tempnam(sys_get_temp_dir(), uniqid()); - file_put_contents($path, $content); - - return new UploadedFile($path, $originalName, $mimeType, $error, true); - } -} diff --git a/vendor/symfony/psr-http-message-bridge/phpunit.xml.dist b/vendor/symfony/psr-http-message-bridge/phpunit.xml.dist deleted file mode 100644 index 43aeaa3387..0000000000 --- a/vendor/symfony/psr-http-message-bridge/phpunit.xml.dist +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<phpunit backupGlobals="false" - backupStaticAttributes="false" - colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" - processIsolation="false" - stopOnFailure="false" - bootstrap="vendor/autoload.php" -> - <testsuites> - <testsuite name="Symfony PSR-7 HTTP message Bridge Test Suite"> - <directory>./Tests/</directory> - </testsuite> - </testsuites> - - <filter> - <whitelist> - <directory>./</directory> - <exclude> - <directory>./Resources</directory> - <directory>./Tests</directory> - <directory>./vendor</directory> - </exclude> - </whitelist> - </filter> -</phpunit> diff --git a/web/modules/google_analytics/composer.json b/web/modules/google_analytics/composer.json index 2baa01c86e..81ea476e6a 100644 --- a/web/modules/google_analytics/composer.json +++ b/web/modules/google_analytics/composer.json @@ -14,9 +14,6 @@ "source": "https://git.drupalcode.org/project/google_analytics" }, "license": "GPL-2.0-or-later", - "require": { - "drupal/core": "^8.9|^9.0" - }, "require-dev": { "drupal/token": "^1.7" }, diff --git a/web/modules/google_analytics/config/install/google_analytics.settings.yml b/web/modules/google_analytics/config/install/google_analytics.settings.yml index 59397fbd38..efd6d0a99e 100644 --- a/web/modules/google_analytics/config/install/google_analytics.settings.yml +++ b/web/modules/google_analytics/config/install/google_analytics.settings.yml @@ -1,5 +1,4 @@ account: '' -premium: false domain_mode: 0 cross_domains: '' visibility: diff --git a/web/modules/google_analytics/config/schema/google_analytics.schema.yml b/web/modules/google_analytics/config/schema/google_analytics.schema.yml index cb15e3b116..6f6edc4fc8 100644 --- a/web/modules/google_analytics/config/schema/google_analytics.schema.yml +++ b/web/modules/google_analytics/config/schema/google_analytics.schema.yml @@ -7,9 +7,6 @@ google_analytics.settings: account: type: string label: 'Web Property ID' - premium: - type: boolean - label: 'Premium account' domain_mode: type: integer label: 'What are you tracking?' diff --git a/web/modules/google_analytics/google_analytics.info.yml b/web/modules/google_analytics/google_analytics.info.yml index ceb8f84cf5..ac66f6b789 100644 --- a/web/modules/google_analytics/google_analytics.info.yml +++ b/web/modules/google_analytics/google_analytics.info.yml @@ -2,12 +2,11 @@ name: 'Google Analytics' type: module description: 'Allows your site to be tracked by Google Analytics by adding a Javascript tracking code to every page.' package: Statistics -core_version_requirement: ^8.9 || ^9 +core_version_requirement: ^9.3 || ^10 configure: google_analytics.admin_settings_form dependencies: - drupal:path_alias - -# Information added by Drupal.org packaging script on 2021-10-14 -version: '4.0.0' +# Information added by Drupal.org packaging script on 2022-09-10 +version: '4.0.2' project: 'google_analytics' -datestamp: 1634230241 +datestamp: 1662768597 diff --git a/web/modules/google_analytics/google_analytics.install b/web/modules/google_analytics/google_analytics.install index 9ae7fbc310..0cf89f1ba7 100644 --- a/web/modules/google_analytics/google_analytics.install +++ b/web/modules/google_analytics/google_analytics.install @@ -146,4 +146,15 @@ function google_analytics_update_8400() { // Save the settings $config->save(); -} \ No newline at end of file +} + +/** + * Drop obsolete config items "ua_legacy" and "premium" from active config. + */ +function google_analytics_update_8401() { + \Drupal::configFactory() + ->getEditable('google_analytics.settings') + ->clear('premium') + ->clear('ua_legacy') + ->save(); +} diff --git a/web/modules/google_analytics/google_analytics.module b/web/modules/google_analytics/google_analytics.module index 35848b624b..e31ae63226 100644 --- a/web/modules/google_analytics/google_analytics.module +++ b/web/modules/google_analytics/google_analytics.module @@ -10,21 +10,15 @@ */ use Drupal\Component\Serialization\Json; -use Drupal\Component\Utility\Crypt; use Drupal\Core\Cache\Cache; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Url; -use Drupal\google_analytics\Event\BuildGaJavascriptEvent; use Drupal\google_analytics\Event\GoogleAnalyticsConfigEvent; use Drupal\google_analytics\Event\GoogleAnalyticsEventsEvent; -use Drupal\google_analytics\Event\PagePathEvent; use Drupal\google_analytics\GaJavascriptObject; use Drupal\google_analytics\Constants\GoogleAnalyticsEvents; -use Drupal\node\NodeInterface; -use GuzzleHttp\Exception\RequestException; use Drupal\google_analytics\Component\Render\GoogleAnalyticsJavaScriptSnippet; -use Drupal\Core\File\FileSystemInterface; /** * Advertise the supported google analytics api details. @@ -99,7 +93,7 @@ function google_analytics_page_attachments(array &$page) { $javascript = new GaJavascriptObject($default_id); // Add link tracking. - $link_settings = ['account' => $default_id]; + $link_settings = ['account' => (string) $default_id]; if ($track_outbound = $config->get('track.outbound')) { $link_settings['trackOutbound'] = $track_outbound; } @@ -126,20 +120,18 @@ function google_analytics_page_attachments(array &$page) { $link_settings['trackUrlFragments'] = $track_url_fragments; } - if (!empty($link_settings)) { - $page['#attached']['drupalSettings']['google_analytics'] = $link_settings; + $page['#attached']['drupalSettings']['google_analytics'] = $link_settings; - // Add debugging code. - if ($debug) { - $page['#attached']['library'][] = 'google_analytics/google_analytics.debug'; - // phpcs:disable - // Add the JS test in development to the page. - // $page['#attached']['library'][] = 'google_analytics/google_analytics.test'; - // phpcs:enable - } - else { - $page['#attached']['library'][] = 'google_analytics/google_analytics'; - } + // Add debugging code. + if ($debug) { + $page['#attached']['library'][] = 'google_analytics/google_analytics.debug'; + // phpcs:disable + // Add the JS test in development to the page. + // $page['#attached']['library'][] = 'google_analytics/google_analytics.test'; + // phpcs:enable + } + else { + $page['#attached']['library'][] = 'google_analytics/google_analytics'; } if ($config->get('track.adsense')) { @@ -170,7 +162,7 @@ function google_analytics_page_attachments(array &$page) { // Get the event_dispatcher service and dispatch the event. $event_dispatcher = \Drupal::service('event_dispatcher'); - $event_dispatcher->dispatch(GoogleAnalyticsEvents::ADD_CONFIG, $ga_config); + $event_dispatcher->dispatch($ga_config, GoogleAnalyticsEvents::ADD_CONFIG); // Json::encode() cannot convert custom URLs properly. $config_array = $ga_config->getConfig(); @@ -195,7 +187,7 @@ function google_analytics_page_attachments(array &$page) { // Get the event_dispatcher service and dispatch the event. $event_dispatcher = \Drupal::service('event_dispatcher'); - $event_dispatcher->dispatch(GoogleAnalyticsEvents::ADD_EVENT, $ga_events); + $event_dispatcher->dispatch($ga_events, GoogleAnalyticsEvents::ADD_EVENT); if (!empty($ga_events->getEvents())) { foreach ($ga_events->getEvents() as $event) { diff --git a/web/modules/google_analytics/google_analytics.services.yml b/web/modules/google_analytics/google_analytics.services.yml index f14dbd6f32..0879cb0332 100644 --- a/web/modules/google_analytics/google_analytics.services.yml +++ b/web/modules/google_analytics/google_analytics.services.yml @@ -7,41 +7,41 @@ services: arguments: [ '@config.factory', '@private_key' ] google_analytics.javascript_cache: class: Drupal\google_analytics\JavascriptLocalCache - arguments: [ '@http_client', '@file_system', '@config.factory', '@logger.factory', '@state' ] + arguments: [ '@http_client', '@file_system', '@config.factory', '@logger.factory', '@state', '@file_url_generator' ] # Google Analytics Event Subscribers google_analytics.events.messages: - class: '\Drupal\google_analytics\EventSubscriber\GoogleAnalyticsEvents\DrupalMessage' + class: Drupal\google_analytics\EventSubscriber\GoogleAnalyticsEvents\DrupalMessage arguments: [ '@config.factory', '@google_analytics.accounts', '@messenger' ] tags: - { name: 'event_subscriber' } google_analytics.pagepath.content_translation: - class: '\Drupal\google_analytics\EventSubscriber\PagePath\ContentTranslation' + class: Drupal\google_analytics\EventSubscriber\PagePath\ContentTranslation arguments: [ '@config.factory', '@request_stack', '@module_handler', '@entity.repository' ] tags: - { name: 'event_subscriber' } google_analytics.pagepath.http_status: - class: '\Drupal\google_analytics\EventSubscriber\PagePath\HttpStatus' + class: Drupal\google_analytics\EventSubscriber\PagePath\HttpStatus arguments: [ '@config.factory', '@request_stack' ] tags: - { name: 'event_subscriber' } google_analytics.pagepath.invalid_user_login: - class: '\Drupal\google_analytics\EventSubscriber\PagePath\InvalidUserLogin' + class: Drupal\google_analytics\EventSubscriber\PagePath\InvalidUserLogin arguments: [ '@request_stack', '@current_route_match' ] tags: - { name: 'event_subscriber' } google_analytics.pagepath.search: - class: '\Drupal\google_analytics\EventSubscriber\PagePath\Search' + class: Drupal\google_analytics\EventSubscriber\PagePath\Search arguments: [ '@config.factory', '@request_stack', '@module_handler', '@current_route_match' ] tags: - { name: 'event_subscriber' } google_analytics.config.default_config: - class: '\Drupal\google_analytics\EventSubscriber\GoogleAnalyticsConfig\DefaultConfig' + class: Drupal\google_analytics\EventSubscriber\GoogleAnalyticsConfig\DefaultConfig arguments: [ '@config.factory', '@google_analytics.accounts', '@current_user' ] tags: - { name: 'event_subscriber' } google_analytics.config.custom_config: - class: '\Drupal\google_analytics\EventSubscriber\GoogleAnalyticsConfig\CustomConfig' + class: Drupal\google_analytics\EventSubscriber\GoogleAnalyticsConfig\CustomConfig arguments: [ '@config.factory', '@current_user', '@request_stack', '@token' ] tags: - { name: 'event_subscriber' } \ No newline at end of file diff --git a/web/modules/google_analytics/migrations/d6_google_analytics_settings.yml b/web/modules/google_analytics/migrations/d6_google_analytics_settings.yml index aa71bcbe77..b8c4e70f1d 100644 --- a/web/modules/google_analytics/migrations/d6_google_analytics_settings.yml +++ b/web/modules/google_analytics/migrations/d6_google_analytics_settings.yml @@ -41,8 +41,11 @@ process: 'codesnippet/before': googleanalytics_codesnippet_before 'codesnippet/create': googleanalytics_codesnippet_create cross_domains: googleanalytics_cross_domains - 'custom/dimension': googleanalytics_custom_dimension - 'custom/metric': googleanalytics_custom_metric + 'custom/parameters': + plugin: google_analytics_parameter_pages + source: + - googleanalytics_custom_dimension + - googleanalytics_custom_metric domain_mode: googleanalytics_domain_mode 'privacy/anonymizeip': googleanalytics_tracker_anonymizeip 'track/adsense': googleanalytics_trackadsense diff --git a/web/modules/google_analytics/migrations/d7_google_analytics_settings.yml b/web/modules/google_analytics/migrations/d7_google_analytics_settings.yml index 25f48ea5b3..16e4202b7f 100644 --- a/web/modules/google_analytics/migrations/d7_google_analytics_settings.yml +++ b/web/modules/google_analytics/migrations/d7_google_analytics_settings.yml @@ -7,7 +7,6 @@ source: plugin: variable variables: - googleanalytics_account - - googleanalytics_premium - googleanalytics_cache - googleanalytics_codesnippet_after - googleanalytics_codesnippet_before @@ -38,14 +37,16 @@ source: source_module: googleanalytics process: account: googleanalytics_account - premium: googleanalytics_premium cache: googleanalytics_cache 'codesnippet/after': googleanalytics_codesnippet_after 'codesnippet/before': googleanalytics_codesnippet_before 'codesnippet/create': googleanalytics_codesnippet_create cross_domains: googleanalytics_cross_domains - 'custom/dimension': googleanalytics_custom_dimension - 'custom/metric': googleanalytics_custom_metric + 'custom/parameters': + plugin: google_analytics_parameter_pages + source: + - googleanalytics_custom_dimension + - googleanalytics_custom_metric domain_mode: googleanalytics_domain_mode 'privacy/anonymizeip': googleanalytics_tracker_anonymizeip 'track/adsense': googleanalytics_trackadsense diff --git a/web/modules/google_analytics/src/Component/Render/GoogleAnalyticsJavaScriptSnippet.php b/web/modules/google_analytics/src/Component/Render/GoogleAnalyticsJavaScriptSnippet.php index 775594f411..fc26be6e3d 100644 --- a/web/modules/google_analytics/src/Component/Render/GoogleAnalyticsJavaScriptSnippet.php +++ b/web/modules/google_analytics/src/Component/Render/GoogleAnalyticsJavaScriptSnippet.php @@ -36,6 +36,7 @@ public function __toString() { /** * {@inheritdoc} */ + #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->__toString(); } diff --git a/web/modules/google_analytics/src/Constants/GoogleAnalyticsPatterns.php b/web/modules/google_analytics/src/Constants/GoogleAnalyticsPatterns.php index 6eaef7b868..da27d106c8 100644 --- a/web/modules/google_analytics/src/Constants/GoogleAnalyticsPatterns.php +++ b/web/modules/google_analytics/src/Constants/GoogleAnalyticsPatterns.php @@ -15,12 +15,12 @@ final class GoogleAnalyticsPatterns { /** * Define the Acceptable GA ID Patterns */ - const GOOGLE_ANALYTICS_GTAG_MATCH = '/(?:UA|G|AW|DC)-[0-9a-zA-Z]{5,}(?:-[0-9]{1,})?/'; + const GOOGLE_ANALYTICS_GTAG_MATCH = '/(?:GT|UA|G|AW|DC)-[0-9a-zA-Z]{5,}(?:-[0-9]{1,})?/'; /** * Define the Acceptable tracking ID patterns */ - const GOOGLE_ANALYTICS_TRACKING_MATCH = '/(?:UA|G)-[0-9a-zA-Z]{5,}(?:-[0-9]{1,})?/'; + const GOOGLE_ANALYTICS_TRACKING_MATCH = '/(?:UA|G|GT)-[0-9a-zA-Z]{5,}(?:-[0-9]{1,})?/'; /** * Define the pattern matching a universal analytics account. diff --git a/web/modules/google_analytics/src/Event/GoogleAnalyticsConfigEvent.php b/web/modules/google_analytics/src/Event/GoogleAnalyticsConfigEvent.php index 03be0c23e0..23b6edf3c6 100644 --- a/web/modules/google_analytics/src/Event/GoogleAnalyticsConfigEvent.php +++ b/web/modules/google_analytics/src/Event/GoogleAnalyticsConfigEvent.php @@ -2,9 +2,8 @@ namespace Drupal\google_analytics\Event; +use Drupal\Component\EventDispatcher\Event; use Drupal\google_analytics\GaAccount; -use Drupal\google_analytics\Helpers\GoogleAnalyticsAccounts; -use Symfony\Component\EventDispatcher\Event; use Drupal\google_analytics\GaJavascriptObject; /** @@ -57,7 +56,7 @@ public function getJavascript() { /** * Get the specific Google Analytics account associated with this config. * - * @return \Drupal\google_analytics\Helpers\GoogleAnalyticsAccounts + * @return \Drupal\google_analytics\GaAccount */ public function getGaAccount() { return $this->gaAccount; diff --git a/web/modules/google_analytics/src/Event/GoogleAnalyticsEventsEvent.php b/web/modules/google_analytics/src/Event/GoogleAnalyticsEventsEvent.php index 5de4e73d35..50804d5d7b 100644 --- a/web/modules/google_analytics/src/Event/GoogleAnalyticsEventsEvent.php +++ b/web/modules/google_analytics/src/Event/GoogleAnalyticsEventsEvent.php @@ -2,7 +2,7 @@ namespace Drupal\google_analytics\Event; -use Symfony\Component\EventDispatcher\Event; +use Drupal\Component\EventDispatcher\Event; use Drupal\google_analytics\GaJavascriptObject; /** diff --git a/web/modules/google_analytics/src/Event/PagePathEvent.php b/web/modules/google_analytics/src/Event/PagePathEvent.php index ee1ac15ee8..bc8c8ad7a3 100644 --- a/web/modules/google_analytics/src/Event/PagePathEvent.php +++ b/web/modules/google_analytics/src/Event/PagePathEvent.php @@ -2,7 +2,7 @@ namespace Drupal\google_analytics\Event; -use Symfony\Component\EventDispatcher\Event; +use Drupal\Component\EventDispatcher\Event; /** * Event that is fired when a user logs in. diff --git a/web/modules/google_analytics/src/EventSubscriber/GoogleAnalyticsConfig/CustomConfig.php b/web/modules/google_analytics/src/EventSubscriber/GoogleAnalyticsConfig/CustomConfig.php index 1ab7813c11..5f7e0a6348 100644 --- a/web/modules/google_analytics/src/EventSubscriber/GoogleAnalyticsConfig/CustomConfig.php +++ b/web/modules/google_analytics/src/EventSubscriber/GoogleAnalyticsConfig/CustomConfig.php @@ -8,7 +8,6 @@ use Drupal\google_analytics\Event\GoogleAnalyticsConfigEvent; use Drupal\google_analytics\Event\GoogleAnalyticsEventsEvent; use Drupal\google_analytics\Constants\GoogleAnalyticsEvents; -use Drupal\google_analytics\Helpers\GoogleAnalyticsAccounts; use Drupal\node\NodeInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\RequestStack; @@ -21,7 +20,7 @@ class CustomConfig implements EventSubscriberInterface { /** * Drupal Config Factory * - * @var \Drupal\Core\Config\ConfigFactoryInterface + * @var \Drupal\Core\Config\ImmutableConfig */ protected $config; @@ -38,7 +37,7 @@ class CustomConfig implements EventSubscriberInterface { protected $token; /** - * @var \Symfony\Component\HttpFoundation\Request|null + * @var \Symfony\Component\HttpFoundation\RequestStack */ protected $request; @@ -64,7 +63,7 @@ class CustomConfig implements EventSubscriberInterface { public function __construct(ConfigFactoryInterface $config_factory, AccountProxyInterface $account, RequestStack $request, Token $token) { $this->config = $config_factory->get('google_analytics.settings'); $this->currentAccount = $account; - $this->request = $request->getCurrentRequest(); + $this->request = $request; $this->token = $token; // Populate custom map/vars @@ -110,14 +109,15 @@ public function onAddEvent(GoogleAnalyticsEventsEvent $event) { protected function populateCustomConfig() { // Add custom dimensions and metrics. - $custom_parameters = $this->config->get('custom.parameters'); + $request = $this->request->getCurrentRequest(); + $custom_parameters = $this->config->get('custom.parameters') ? $this->config->get('custom.parameters') : []; if (!empty($custom_parameters)) { // Add all the configured variables to the content. foreach ($custom_parameters as $index => $custom_parameter) { // Replace tokens in values. $types = []; - if ($this->request->attributes->has('node')) { - $node = $this->request->attributes->get('node'); + if ($request->attributes->has('node')) { + $node = $request->attributes->get('node'); if ($node instanceof NodeInterface) { $types += ['node' => $node]; } diff --git a/web/modules/google_analytics/src/EventSubscriber/GoogleAnalyticsConfig/DefaultConfig.php b/web/modules/google_analytics/src/EventSubscriber/GoogleAnalyticsConfig/DefaultConfig.php index dd94fab06c..2aad402b0d 100644 --- a/web/modules/google_analytics/src/EventSubscriber/GoogleAnalyticsConfig/DefaultConfig.php +++ b/web/modules/google_analytics/src/EventSubscriber/GoogleAnalyticsConfig/DefaultConfig.php @@ -18,7 +18,7 @@ class DefaultConfig implements EventSubscriberInterface { /** * Drupal Config Factory * - * @var \Drupal\Core\Config\ConfigFactoryInterface + * @var \Drupal\Core\Config\ImmutableConfig */ protected $config; @@ -78,12 +78,12 @@ public function onAddConfig(GoogleAnalyticsConfigEvent $event) { // Domain tracking type. global $cookie_domain; - $domain_mode = $this->config->get('domain_mode'); + $domain_mode = (int)($this->config->get('domain_mode') ? $this->config->get('domain_mode') : 0); // Per RFC 2109, cookie domains must contain at least one dot other than the // first. For hosts such as 'localhost' or IP Addresses we don't set a // cookie domain. - if ($domain_mode == 1 && count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) { + if (!empty($cookie_domain) && $domain_mode == 1 && count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) { $arguments = array_merge($arguments, ['cookie_domain' => $cookie_domain]); $javascript->setAdsenseScript($cookie_domain); } @@ -109,7 +109,7 @@ public function onAddConfig(GoogleAnalyticsConfigEvent $event) { $page_path = new PagePathEvent(); // Get the event_dispatcher service and dispatch the event. $event_dispatcher = \Drupal::service('event_dispatcher'); - $event_dispatcher->dispatch(GoogleAnalyticsEvents::PAGE_PATH, $page_path); + $event_dispatcher->dispatch($page_path, GoogleAnalyticsEvents::PAGE_PATH); $path_type = $ga_account->isUniversalAnalyticsAccount() ? 'page_path' : 'page_location'; $arguments['page_placeholder'] = 'PLACEHOLDER_' . $path_type; diff --git a/web/modules/google_analytics/src/EventSubscriber/PagePath/ContentTranslation.php b/web/modules/google_analytics/src/EventSubscriber/PagePath/ContentTranslation.php index 4cde9ecbb5..7cf6d0bd80 100644 --- a/web/modules/google_analytics/src/EventSubscriber/PagePath/ContentTranslation.php +++ b/web/modules/google_analytics/src/EventSubscriber/PagePath/ContentTranslation.php @@ -5,13 +5,13 @@ use Drupal\Component\Serialization\Json; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityRepositoryInterface; -use Drupal\Core\Extension\ModuleHandler; +use Drupal\Core\Extension\ModuleHandlerInterface; +use Symfony\Component\HttpFoundation\RequestStack; use Drupal\Core\Url; use Drupal\google_analytics\Event\PagePathEvent; use Drupal\google_analytics\Constants\GoogleAnalyticsEvents; use Drupal\node\NodeInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpFoundation\RequestStack; /** * Adds Content Translation to custom URL @@ -33,7 +33,7 @@ class ContentTranslation implements EventSubscriberInterface { protected $messenger; /** - * @var \GuzzleHttp\Psr7\Request + * @var \Symfony\Component\HttpFoundation\RequestStack */ protected $request; @@ -58,11 +58,11 @@ class ContentTranslation implements EventSubscriberInterface { * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * Config Factory for Google Analytics Settings. */ - public function __construct(ConfigFactoryInterface $config_factory, RequestStack $request, ModuleHandler $module_handler, EntityRepositoryInterface $entity_repsoitory) { + public function __construct(ConfigFactoryInterface $config_factory, RequestStack $request, ModuleHandlerInterface $module_handler, EntityRepositoryInterface $entity_repsoitory) { $this->config = $config_factory->get('google_analytics.settings'); - $this->request = $request->getCurrentRequest(); $this->moduleHandler = $module_handler; $this->entityRepository = $entity_repsoitory; + $this->request = $request; } /** @@ -85,11 +85,12 @@ public function onPagePath(PagePathEvent $event) { // Site search tracking support. // If this node is a translation of another node, pass the original // node instead. + $request = $this->request->getCurrentRequest(); if ($this->moduleHandler->moduleExists('content_translation') && $this->config->get('translation_set')) { // Check if we have a node object, it has translation enabled, and its // language code does not match its source language code. - if ($this->request->attributes->has('node')) { - $node = $this->request->attributes->get('node'); + if ($request->attributes->has('node')) { + $node = $request->attributes->get('node'); if ($node instanceof NodeInterface && $this->entityRepository->getTranslationFromContext($node) !== $node->getUntranslated()) { $url_custom = Json::encode(Url::fromRoute('entity.node.canonical', ['node' => $node->id()], ['language' => $node->getUntranslated()->language()])->toString()); $event->setPagePath($url_custom); diff --git a/web/modules/google_analytics/src/EventSubscriber/PagePath/HttpStatus.php b/web/modules/google_analytics/src/EventSubscriber/PagePath/HttpStatus.php index 87c290ed87..1e70beef20 100644 --- a/web/modules/google_analytics/src/EventSubscriber/PagePath/HttpStatus.php +++ b/web/modules/google_analytics/src/EventSubscriber/PagePath/HttpStatus.php @@ -3,10 +3,10 @@ namespace Drupal\google_analytics\EventSubscriber\PagePath; use Drupal\Core\Config\ConfigFactoryInterface; +use Symfony\Component\HttpFoundation\RequestStack; use Drupal\google_analytics\Event\PagePathEvent; use Drupal\google_analytics\Constants\GoogleAnalyticsEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpFoundation\RequestStack; /** * Adds Content Translation to custom URL @@ -21,7 +21,7 @@ class HttpStatus implements EventSubscriberInterface { protected $config; /** - * @var \GuzzleHttp\Psr7\Request + * @var \Symfony\Component\HttpFoundation\RequestStack */ protected $request; @@ -33,7 +33,7 @@ class HttpStatus implements EventSubscriberInterface { */ public function __construct(ConfigFactoryInterface $config_factory, RequestStack $request) { $this->config = $config_factory->get('google_analytics.settings'); - $this->request = $request->getCurrentRequest(); + $this->request = $request; } /** @@ -55,7 +55,8 @@ public static function getSubscribedEvents() { public function onPagePath(PagePathEvent $event) { // Get page http status code for visibility filtering. $status = NULL; - if ($exception = $this->request->attributes->get('exception')) { + $request = $this->request->getCurrentRequest(); + if ($exception = $request->attributes->get('exception')) { $status = $exception->getStatusCode(); } // TODO: Make configurable diff --git a/web/modules/google_analytics/src/EventSubscriber/PagePath/InvalidUserLogin.php b/web/modules/google_analytics/src/EventSubscriber/PagePath/InvalidUserLogin.php index 482b3ac2b6..6caeba57ca 100644 --- a/web/modules/google_analytics/src/EventSubscriber/PagePath/InvalidUserLogin.php +++ b/web/modules/google_analytics/src/EventSubscriber/PagePath/InvalidUserLogin.php @@ -2,11 +2,11 @@ namespace Drupal\google_analytics\EventSubscriber\PagePath; +use Symfony\Component\HttpFoundation\RequestStack; use Drupal\Core\Routing\CurrentRouteMatch; use Drupal\google_analytics\Event\PagePathEvent; use Drupal\google_analytics\Constants\GoogleAnalyticsEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpFoundation\RequestStack; /** * Adds Content Translation to custom URL @@ -14,7 +14,7 @@ class InvalidUserLogin implements EventSubscriberInterface { /** - * @var \GuzzleHttp\Psr7\Request + * @var \Symfony\Component\HttpFoundation\RequestStack */ protected $request; @@ -24,13 +24,15 @@ class InvalidUserLogin implements EventSubscriberInterface { protected $currentRoute; /** - * DrupalMessage constructor. + * Invalid User Login Path * - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * Config Factory for Google Analytics Settings. + * @param \Symfony\Component\HttpFoundation\RequestStack $request + * The current request stack. + * @param \Drupal\Core\Routing\CurrentRouteMatch $current_route + * The current route. */ public function __construct(RequestStack $request, CurrentRouteMatch $current_route) { - $this->request = $request->getCurrentRequest(); + $this->request = $request; $this->currentRoute = $current_route; } @@ -60,7 +62,8 @@ public function onPagePath(PagePathEvent $event) { // - user/password?name=username // - user/password?name=foo@example.com $base_path = base_path(); - if ($this->currentRoute->getRouteName() == 'user.pass' && $this->request->query->has('name')) { + $request = $this->request->getCurrentRequest(); + if ($this->currentRoute->getRouteName() == 'user.pass' && $request->query->has('name')) { $event->setPagePath('"' . $base_path . 'user/password"'); $event->stopPropagation(); } diff --git a/web/modules/google_analytics/src/EventSubscriber/PagePath/Search.php b/web/modules/google_analytics/src/EventSubscriber/PagePath/Search.php index a6ce9b4196..d184e3323d 100644 --- a/web/modules/google_analytics/src/EventSubscriber/PagePath/Search.php +++ b/web/modules/google_analytics/src/EventSubscriber/PagePath/Search.php @@ -4,13 +4,13 @@ use Drupal\Component\Serialization\Json; use Drupal\Core\Config\ConfigFactoryInterface; -use Drupal\Core\Extension\ModuleHandler; +use Drupal\Core\Extension\ModuleHandlerInterface; +use Symfony\Component\HttpFoundation\RequestStack; use Drupal\Core\Routing\CurrentRouteMatch; use Drupal\Core\Url; use Drupal\google_analytics\Event\PagePathEvent; use Drupal\google_analytics\Constants\GoogleAnalyticsEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpFoundation\RequestStack; /** * Adds Drupal Messages to GA Javascript. @@ -25,7 +25,7 @@ class Search implements EventSubscriberInterface { protected $config; /** - * @var \GuzzleHttp\Psr7\Request + * @var \Symfony\Component\HttpFoundation\RequestStack */ protected $request; @@ -45,9 +45,9 @@ class Search implements EventSubscriberInterface { * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * Config Factory for Google Analytics Settings. */ - public function __construct(ConfigFactoryInterface $config_factory, RequestStack $request, ModuleHandler $module_handler, CurrentRouteMatch $current_route) { + public function __construct(ConfigFactoryInterface $config_factory, RequestStack $request, ModuleHandlerInterface $module_handler, CurrentRouteMatch $current_route) { $this->config = $config_factory->get('google_analytics.settings'); - $this->request = $request->getCurrentRequest(); + $this->request = $request; $this->moduleHandler = $module_handler; $this->currentRoute = $current_route; @@ -71,7 +71,8 @@ public static function getSubscribedEvents() { */ public function onCustomPagePath(PagePathEvent $event) { // Site search tracking support. - if ($this->moduleHandler->moduleExists('search') && $this->config->get('track.site_search') && (strpos($this->currentRoute->getRouteName(), 'search.view') === 0) && $keys = ($this->request->query->has('keys') ? trim($this->request->get('keys')) : '')) { + $request = $this->request->getCurrentRequest(); + if ($this->moduleHandler->moduleExists('search') && $this->config->get('track.site_search') && (strpos($this->currentRoute->getRouteName(), 'search.view') === 0) && $keys = ($request->query->has('keys') ? trim($request->get('keys')) : '')) { // hook_item_list__search_results() is not executed if search result is // empty. Make sure the counter is set to 0 if there are no results. $entity = $this->currentRoute->getParameter('entity'); diff --git a/web/modules/google_analytics/src/Form/GoogleAnalyticsAdminSettingsForm.php b/web/modules/google_analytics/src/Form/GoogleAnalyticsAdminSettingsForm.php index c7810a74ad..320c36662b 100644 --- a/web/modules/google_analytics/src/Form/GoogleAnalyticsAdminSettingsForm.php +++ b/web/modules/google_analytics/src/Form/GoogleAnalyticsAdminSettingsForm.php @@ -142,7 +142,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['general']['accounts'][$i]['#attributes']['class'][] = 'draggable'; $form['general']['accounts'][$i]['#weight'] = $i; $form['general']['accounts'][$i]['value'] = [ - '#default_value' => (string)$accounts[$i] ?? '', + '#default_value' => (string)($accounts[$i] ?? ''), '#maxlength' => 20, '#required' => ($i === 0), '#size' => 20, @@ -152,7 +152,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['general']['accounts'][$i]['weight'] = [ '#type' => 'weight', - '#title' => $this->t('Weight for @title', ['@title' => (string)$accounts[$i]]), + '#title' => $this->t('Weight for @title', ['@title' => (string)($accounts[$i] ?? '')]), '#title_display' => 'invisible', '#delta' => 50, '#default_value' => $i, @@ -208,7 +208,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { global $cookie_domain; $multiple_sub_domains = []; foreach (['www', 'app', 'shop'] as $subdomain) { - if (count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) { + if (!empty($cookie_domain) && count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) { $multiple_sub_domains[] = $subdomain . $cookie_domain; } // IP addresses or localhost. @@ -792,7 +792,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $config ->set('account', $accounts) - ->set('ua_legacy', $form_state->getValue('google_analytics_legacy')) ->set('cross_domains', $form_state->getValue('google_analytics_cross_domains')) ->set('codesnippet.create', $form_state->getValue('google_analytics_codesnippet_create')) ->set('codesnippet.before', $form_state->getValue('google_analytics_codesnippet_before')) diff --git a/web/modules/google_analytics/src/JavascriptLocalCache.php b/web/modules/google_analytics/src/JavascriptLocalCache.php index 0d72efea41..cd194d91d6 100644 --- a/web/modules/google_analytics/src/JavascriptLocalCache.php +++ b/web/modules/google_analytics/src/JavascriptLocalCache.php @@ -5,6 +5,7 @@ use Drupal\Component\Utility\Crypt; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\File\FileSystemInterface; +use Drupal\Core\File\FileUrlGeneratorInterface; use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\State\StateInterface; use GuzzleHttp\ClientInterface; @@ -42,12 +43,18 @@ class JavascriptLocalCache { */ protected $state; - public function __construct(ClientInterface $http_client, FileSystemInterface $file_system, ConfigFactoryInterface $config_factory, LoggerChannelFactoryInterface $logger_factory, StateInterface $state) { + /** + * @var \Drupal\Core\File\FileUrlGeneratorInterface + */ + protected $fileUrlGenerator; + + public function __construct(ClientInterface $http_client, FileSystemInterface $file_system, ConfigFactoryInterface $config_factory, LoggerChannelFactoryInterface $logger_factory, StateInterface $state, FileUrlGeneratorInterface $file_url_generator) { $this->httpClient = $http_client; $this->fileSystem = $file_system; $this->configFactory = $config_factory; $this->state = $state; $this->logger = $logger_factory->get('google_analytics'); + $this->fileUrlGenerator = $file_url_generator; } /** * Download/Synchronize/Cache tracking code file locally. @@ -117,7 +124,7 @@ public function fetchGoogleAnalyticsJavascript(string $tracking_id, bool $synchr } // Return the local JS file path. $query_string = '?' . (\Drupal::state()->get('system.css_js_query_string') ?: '0'); - return file_url_transform_relative(file_create_url($file_destination)) . $query_string; + return $this->fileUrlGenerator->generateString($file_destination) . $query_string; } /** diff --git a/web/modules/google_analytics/src/Plugin/migrate/process/GoogleAnalyticsParameterPages.php b/web/modules/google_analytics/src/Plugin/migrate/process/GoogleAnalyticsParameterPages.php new file mode 100644 index 0000000000..6ae5fb1f09 --- /dev/null +++ b/web/modules/google_analytics/src/Plugin/migrate/process/GoogleAnalyticsParameterPages.php @@ -0,0 +1,93 @@ +<?php + +namespace Drupal\google_analytics\Plugin\migrate\process; + +use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\Plugin\MigrateProcessInterface; +use Drupal\migrate\Plugin\MigrationInterface; +use Drupal\migrate\ProcessPluginBase; +use Drupal\migrate\Row; +use Symfony\Component\DependencyInjection\ContainerInterface; + +/** + * Converts D7 dimension and metric to D8 in a single field. + * + * @MigrateProcessPlugin( + * id = "google_analytics_parameter_pages" + * ) + */ +class GoogleAnalyticsParameterPages extends ProcessPluginBase implements ContainerFactoryPluginInterface { + + /** + * The module handler. + * + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected $moduleHandler; + + /** + * The migration process plugin. + * + * The migration process plugin, configured for lookups in the d6_user_role + * and d7_user_role migrations. + * + * @var \Drupal\migrate\Plugin\MigrateProcessInterface + */ + protected $migrationPlugin; + + /** + * {@inheritdoc} + */ + public function __construct(array $configuration, $plugin_id, $plugin_definition, ModuleHandlerInterface $module_handler, MigrateProcessInterface $migration_plugin) { + parent::__construct($configuration, $plugin_id, $plugin_definition); + $this->moduleHandler = $module_handler; + $this->migrationPlugin = $migration_plugin; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { + $migration_configuration = [ + 'migration' => [ + 'd6_user_role', + 'd7_user_role', + ], + ]; + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('module_handler'), + $container->get('plugin.manager.migrate.process')->createInstance('migration_lookup', $migration_configuration, $migration) + ); + } + + /** + * {@inheritdoc} + */ + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { + [$dimensions, $metrics] = $value; + $return_array = []; + foreach ($dimensions as $dimension) { + $index = 'dimension' . $dimension['index']; + $return_array[$index] = [ + 'type' => 'dimension', + 'name' => $index, + 'value' => $dimension['value'], + ]; + } + foreach ($metrics as $metric) { + $index = 'metric' . $metric['index']; + $return_array[$index] = [ + 'type' => 'metric', + 'name' => $index, + 'value' => $metric['value'], + ]; + } + return $return_array; + } + +} diff --git a/web/modules/google_analytics/src/Plugin/migrate/process/GoogleAnalyticsVisibilityPages.php b/web/modules/google_analytics/src/Plugin/migrate/process/GoogleAnalyticsVisibilityPages.php index 23a26abca2..45fe8bf30d 100644 --- a/web/modules/google_analytics/src/Plugin/migrate/process/GoogleAnalyticsVisibilityPages.php +++ b/web/modules/google_analytics/src/Plugin/migrate/process/GoogleAnalyticsVisibilityPages.php @@ -70,7 +70,7 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { - list($old_visibility, $pages) = $value; + [$old_visibility, $pages] = $value; $request_path_pages = ''; diff --git a/web/modules/google_analytics/src/Plugin/migrate/process/GoogleAnalyticsVisibilityRoles.php b/web/modules/google_analytics/src/Plugin/migrate/process/GoogleAnalyticsVisibilityRoles.php index c6b4374e32..6884d9ccb9 100644 --- a/web/modules/google_analytics/src/Plugin/migrate/process/GoogleAnalyticsVisibilityRoles.php +++ b/web/modules/google_analytics/src/Plugin/migrate/process/GoogleAnalyticsVisibilityRoles.php @@ -69,7 +69,7 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { - list($roles) = $value; + [$roles] = $value; // Remove role IDs disabled in D6/D7. $roles = array_filter($roles); diff --git a/web/modules/google_analytics/tests/modules/google_analytics_test/google_analytics_test.info.yml b/web/modules/google_analytics/tests/modules/google_analytics_test/google_analytics_test.info.yml index a347aa514f..99c0e9a269 100644 --- a/web/modules/google_analytics/tests/modules/google_analytics_test/google_analytics_test.info.yml +++ b/web/modules/google_analytics/tests/modules/google_analytics_test/google_analytics_test.info.yml @@ -3,7 +3,7 @@ type: module description: 'Support module for Google Analytics testing.' package: Testing -# Information added by Drupal.org packaging script on 2021-10-14 -version: '4.0.0' +# Information added by Drupal.org packaging script on 2022-09-10 +version: '4.0.2' project: 'google_analytics' -datestamp: 1634230241 +datestamp: 1662768597 diff --git a/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsBasicTest.php b/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsBasicTest.php index 105f3630c3..d050f8f15b 100644 --- a/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsBasicTest.php +++ b/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsBasicTest.php @@ -36,7 +36,7 @@ class GoogleAnalyticsBasicTest extends BrowserTestBase { * * @var array */ - public static $modules = [ + protected static $modules = [ 'block', 'google_analytics', 'help', @@ -101,9 +101,9 @@ public function testGoogleAnalyticsConfiguration() { $this->assertSession()->fieldExists('google_analytics_codesnippet_create'); $this->assertSession()->fieldExists('google_analytics_codesnippet_before'); $this->assertSession()->fieldExists('google_analytics_codesnippet_after'); - $this->assertNoFieldByXPath("//textarea[@name='google_analytics_codesnippet_create' and @disabled='disabled']", NULL, '"Parameters" field is enabled.'); - $this->assertNoFieldByXPath("//textarea[@name='google_analytics_codesnippet_before' and @disabled='disabled']", NULL, '"Code snippet (before)" is enabled.'); - $this->assertNoFieldByXPath("//textarea[@name='google_analytics_codesnippet_after' and @disabled='disabled']", NULL, '"Code snippet (after)" is enabled.'); + $this->assertEmpty($this->xpath("//textarea[@name='google_analytics_codesnippet_create' and @disabled='disabled']"), '"Parameters" field is enabled.'); + $this->assertEmpty($this->xpath("//textarea[@name='google_analytics_codesnippet_before' and @disabled='disabled']"), '"Code snippet (before)" is enabled.'); + $this->assertEmpty($this->xpath("//textarea[@name='google_analytics_codesnippet_after' and @disabled='disabled']"), '"Code snippet (after)" is enabled.'); // Login as user without JS permissions. $this->drupalLogin($this->noSnippetUser); @@ -113,9 +113,9 @@ public function testGoogleAnalyticsConfiguration() { $this->assertSession()->fieldExists('google_analytics_codesnippet_create'); $this->assertSession()->fieldExists('google_analytics_codesnippet_before'); $this->assertSession()->fieldExists('google_analytics_codesnippet_after'); - $this->assertNoFieldByXPath("//textarea[@name='google_analytics_codesnippet_create' and @disabled='disabled']", NULL, '"Parameters" field is enabled.'); - $this->assertFieldByXPath("//textarea[@name='google_analytics_codesnippet_before' and @disabled='disabled']", NULL, '"Code snippet (before)" is disabled.'); - $this->assertFieldByXPath("//textarea[@name='google_analytics_codesnippet_after' and @disabled='disabled']", NULL, '"Code snippet (after)" is disabled.'); + $this->assertEmpty($this->xpath("//textarea[@name='google_analytics_codesnippet_create' and @disabled='disabled']"), '"Parameters" field is enabled.'); + $this->assertNotEmpty($this->xpath("//textarea[@name='google_analytics_codesnippet_before' and @disabled='disabled']"), '"Code snippet (before)" is disabled.'); + $this->assertNotEmpty($this->xpath("//textarea[@name='google_analytics_codesnippet_after' and @disabled='disabled']"), '"Code snippet (after)" is disabled.'); } /** diff --git a/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsCustomDimensionsAndMetricsTest.php b/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsCustomDimensionsAndMetricsTest.php index 3625a2d2c0..d639042924 100644 --- a/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsCustomDimensionsAndMetricsTest.php +++ b/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsCustomDimensionsAndMetricsTest.php @@ -22,7 +22,7 @@ class GoogleAnalyticsCustomDimensionsAndMetricsTest extends BrowserTestBase { * * @var array */ - public static $modules = ['google_analytics', 'token', 'node']; + protected static $modules = ['google_analytics', 'token', 'node']; /** * Default theme. @@ -41,7 +41,7 @@ class GoogleAnalyticsCustomDimensionsAndMetricsTest extends BrowserTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $permissions = [ @@ -160,7 +160,7 @@ public function testGoogleAnalyticsCustomDimensions() { ], ]; $this->config('google_analytics.settings')->set('custom.parameters', $google_analytics_custom_dimension)->save(); - $this->verbose('<pre>' . print_r($google_analytics_custom_dimension, TRUE) . '</pre>'); + dump('<pre>' . print_r($google_analytics_custom_dimension, TRUE) . '</pre>'); // Test on frontpage. $this->drupalGet(''); diff --git a/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsCustomUrls.php b/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsCustomUrls.php index 9d2d3ecb07..d12d691158 100644 --- a/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsCustomUrls.php +++ b/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsCustomUrls.php @@ -17,7 +17,7 @@ class GoogleAnalyticsCustomUrls extends BrowserTestBase { * * @var array */ - public static $modules = ['google_analytics']; + protected static $modules = ['google_analytics']; /** * Default theme. @@ -36,7 +36,7 @@ class GoogleAnalyticsCustomUrls extends BrowserTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $permissions = [ diff --git a/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsRolesTest.php b/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsRolesTest.php index 803375fdb4..32b36b87c3 100644 --- a/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsRolesTest.php +++ b/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsRolesTest.php @@ -17,7 +17,7 @@ class GoogleAnalyticsRolesTest extends BrowserTestBase { * * @var array */ - public static $modules = ['google_analytics']; + protected static $modules = ['google_analytics']; /** * Default theme. @@ -36,7 +36,7 @@ class GoogleAnalyticsRolesTest extends BrowserTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $permissions = [ diff --git a/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsSearchTest.php b/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsSearchTest.php index 9d80cfbe2d..54769e5090 100644 --- a/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsSearchTest.php +++ b/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsSearchTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\google_analytics\Functional; -use Drupal\Component\Serialization\Json; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\search\SearchIndexInterface; use Drupal\Tests\BrowserTestBase; @@ -15,13 +14,13 @@ class GoogleAnalyticsSearchTest extends BrowserTestBase { use StringTranslationTrait; - + /** * Modules to enable. * * @var array */ - public static $modules = ['google_analytics', 'search', 'node']; + protected static $modules = ['google_analytics', 'search', 'node']; /** * Admin user. @@ -40,7 +39,7 @@ class GoogleAnalyticsSearchTest extends BrowserTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']); diff --git a/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsStatusMessagesTest.php b/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsStatusMessagesTest.php index c00903783d..b1b3d8b50f 100644 --- a/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsStatusMessagesTest.php +++ b/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsStatusMessagesTest.php @@ -19,7 +19,7 @@ class GoogleAnalyticsStatusMessagesTest extends BrowserTestBase { * * @var array */ - public static $modules = ['google_analytics', 'google_analytics_test']; + protected static $modules = ['google_analytics', 'google_analytics_test']; /** * Default theme. @@ -38,7 +38,7 @@ class GoogleAnalyticsStatusMessagesTest extends BrowserTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $permissions = [ diff --git a/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsUninstallTest.php b/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsUninstallTest.php index 0e25299cc0..ba22e458c1 100644 --- a/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsUninstallTest.php +++ b/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsUninstallTest.php @@ -19,7 +19,7 @@ class GoogleAnalyticsUninstallTest extends BrowserTestBase { * * @var array */ - public static $modules = ['google_analytics']; + protected static $modules = ['google_analytics']; /** * Default theme. @@ -38,7 +38,7 @@ class GoogleAnalyticsUninstallTest extends BrowserTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $permissions = [ diff --git a/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsUserFieldsTest.php b/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsUserFieldsTest.php index 2c14661dbb..c096c81c21 100644 --- a/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsUserFieldsTest.php +++ b/web/modules/google_analytics/tests/src/Functional/GoogleAnalyticsUserFieldsTest.php @@ -19,7 +19,7 @@ class GoogleAnalyticsUserFieldsTest extends BrowserTestBase { * * @var array */ - public static $modules = ['google_analytics', 'field_ui']; + protected static $modules = ['google_analytics', 'field_ui']; /** * Default theme. @@ -38,7 +38,7 @@ class GoogleAnalyticsUserFieldsTest extends BrowserTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $permissions = [ diff --git a/web/modules/google_analytics/tests/src/FunctionalJavascript/GoogleAnalyticsFormValidationTest.php b/web/modules/google_analytics/tests/src/FunctionalJavascript/GoogleAnalyticsFormValidationTest.php index 5765257ba8..504401fa3f 100644 --- a/web/modules/google_analytics/tests/src/FunctionalJavascript/GoogleAnalyticsFormValidationTest.php +++ b/web/modules/google_analytics/tests/src/FunctionalJavascript/GoogleAnalyticsFormValidationTest.php @@ -36,7 +36,7 @@ class GoogleAnalyticsFormValidationTest extends WebDriverTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $permissions = [ diff --git a/web/modules/google_analytics/tests/src/Kernel/Form/GoogleAnalyticsAdminSettingsFormTest.php b/web/modules/google_analytics/tests/src/Kernel/Form/GoogleAnalyticsAdminSettingsFormTest.php index 57a835d953..e8c2e0ec03 100644 --- a/web/modules/google_analytics/tests/src/Kernel/Form/GoogleAnalyticsAdminSettingsFormTest.php +++ b/web/modules/google_analytics/tests/src/Kernel/Form/GoogleAnalyticsAdminSettingsFormTest.php @@ -37,7 +37,7 @@ class GoogleAnalyticsAdminSettingsFormTest extends KernelTestBase { * * @covers ::__construct */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installConfig(static::$modules); -- GitLab