From e396fc61e88c01bf77b81a25e4cd1bece54e8deb Mon Sep 17 00:00:00 2001 From: Michael Lee <lee.5151@osu.edu> Date: Mon, 12 Sep 2022 11:25:57 -0400 Subject: [PATCH] Upgrading drupal/admin_toolbar (3.1.0 => 3.1.1) --- composer.json | 2 +- composer.lock | 36 +-- vendor/composer/installed.json | 38 +-- 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 -- .../admin_toolbar/admin_toolbar.info.yml | 6 +- ...admin_toolbar_links_access_filter.info.yml | 6 +- .../admin_toolbar_links_access_filter.module | 5 + .../admin_toolbar_search.info.yml | 6 +- .../schema/admin_toolbar_search.schema.yml | 2 +- .../js/admin_toolbar_search.js | 2 +- .../Form/AdminToolbarSearchSettingsForm.php | 2 +- .../admin_toolbar_tools.info.yml | 6 +- .../admin_toolbar_tools.module | 44 +++ .../admin_toolbar_tools.services.yml | 2 + .../install/admin_toolbar_tools.settings.yml | 1 + .../schema/admin_toolbar_tools.schema.yml | 3 + .../admin_toolbar_tools/css/tools.css | 12 + .../misc/icons/bebebe/tasks.svg | 4 + .../src/AdminToolbarToolsHelper.php | 67 ++++- .../Form/AdminToolbarToolsSettingsForm.php | 8 + .../src/Plugin/Derivative/ExtraLinks.php | 15 +- .../admin_toolbar/css/admin.toolbar.css | 4 +- web/modules/admin_toolbar/js/admin_toolbar.js | 3 +- .../src/Render/Element/AdminToolbar.php | 2 +- .../Functional/AdminToolbarAdminMenuTest.php | 23 ++ 48 files changed, 257 insertions(+), 2033 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/admin_toolbar/admin_toolbar_tools/misc/icons/bebebe/tasks.svg create mode 100644 web/modules/admin_toolbar/tests/src/Functional/AdminToolbarAdminMenuTest.php diff --git a/composer.json b/composer.json index 981336c14f..94910c4418 100644 --- a/composer.json +++ b/composer.json @@ -88,7 +88,7 @@ "desandro/masonry": "4.2", "dimsemenov/magnific-popup": "1.1", "drupal/addtocalendar": "3.2", - "drupal/admin_toolbar": "3.1.0", + "drupal/admin_toolbar": "3.1.1", "drupal/administerusersbyrole": "3.0", "drupal/allowed_formats": "1.5", "drupal/anchor_link": "1.9", diff --git a/composer.lock b/composer.lock index 7aabbfe6b3..3d84be1805 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": "0e54b39762d2013e58ec32f6ed309f10", "packages": [ { "name": "alchemy/zippy", @@ -1746,17 +1746,17 @@ }, { "name": "drupal/admin_toolbar", - "version": "3.1.0", + "version": "3.1.1", "source": { "type": "git", "url": "https://git.drupalcode.org/project/admin_toolbar.git", - "reference": "3.1.0" + "reference": "3.1.1" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/admin_toolbar-3.1.0.zip", - "reference": "3.1.0", - "shasum": "7b596d7de04faca747ba3e5216c2e819aae71f40" + "url": "https://ftp.drupal.org/files/projects/admin_toolbar-3.1.1.zip", + "reference": "3.1.1", + "shasum": "a66ce69cd7e56f1cc43797dc2a58d6eab367d353" }, "require": { "drupal/core": "^8.8.0 || ^9.0 || ^10.0" @@ -1767,8 +1767,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "3.1.0", - "datestamp": "1643742891", + "version": "3.1.1", + "datestamp": "1658802262", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" @@ -1801,14 +1801,14 @@ "homepage": "https://www.drupal.org/u/matio89", "role": "Maintainer" }, - { - "name": "fethi.krout", - "homepage": "https://www.drupal.org/user/3206765" - }, { "name": "matio89", "homepage": "https://www.drupal.org/user/2320090" }, + { + "name": "Musa.thomas", + "homepage": "https://www.drupal.org/user/1213824" + }, { "name": "romainj", "homepage": "https://www.drupal.org/user/370706" @@ -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..93609b42da 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1790,18 +1790,18 @@ }, { "name": "drupal/admin_toolbar", - "version": "3.1.0", - "version_normalized": "3.1.0.0", + "version": "3.1.1", + "version_normalized": "3.1.1.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/admin_toolbar.git", - "reference": "3.1.0" + "reference": "3.1.1" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/admin_toolbar-3.1.0.zip", - "reference": "3.1.0", - "shasum": "7b596d7de04faca747ba3e5216c2e819aae71f40" + "url": "https://ftp.drupal.org/files/projects/admin_toolbar-3.1.1.zip", + "reference": "3.1.1", + "shasum": "a66ce69cd7e56f1cc43797dc2a58d6eab367d353" }, "require": { "drupal/core": "^8.8.0 || ^9.0 || ^10.0" @@ -1812,8 +1812,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "3.1.0", - "datestamp": "1643097060", + "version": "3.1.1", + "datestamp": "1658802262", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" @@ -1847,14 +1847,14 @@ "homepage": "https://www.drupal.org/u/matio89", "role": "Maintainer" }, - { - "name": "fethi.krout", - "homepage": "https://www.drupal.org/user/3206765" - }, { "name": "matio89", "homepage": "https://www.drupal.org/user/2320090" }, + { + "name": "Musa.thomas", + "homepage": "https://www.drupal.org/user/1213824" + }, { "name": "romainj", "homepage": "https://www.drupal.org/user/370706" @@ -14929,17 +14929,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 +14960,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 +15000,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..b3c270d8bd 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(), @@ -287,9 +287,9 @@ 'dev_requirement' => false, ), 'drupal/admin_toolbar' => array( - 'pretty_version' => '3.1.0', - 'version' => '3.1.0.0', - 'reference' => '3.1.0', + 'pretty_version' => '3.1.1', + 'version' => '3.1.1.0', + 'reference' => '3.1.1', 'type' => 'drupal-module', 'install_path' => __DIR__ . '/../../web/modules/admin_toolbar', '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/admin_toolbar/admin_toolbar.info.yml b/web/modules/admin_toolbar/admin_toolbar.info.yml index 958ddec165..bf2aaf8021 100644 --- a/web/modules/admin_toolbar/admin_toolbar.info.yml +++ b/web/modules/admin_toolbar/admin_toolbar.info.yml @@ -6,7 +6,7 @@ core_version_requirement: ^8.8.0 || ^9 || ^10 dependencies: - drupal:toolbar -# Information added by Drupal.org packaging script on 2022-01-25 -version: '3.1.0' +# Information added by Drupal.org packaging script on 2022-07-26 +version: '3.1.1' project: 'admin_toolbar' -datestamp: 1643097063 +datestamp: 1658801856 diff --git a/web/modules/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.info.yml b/web/modules/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.info.yml index 68010d988c..d602944381 100644 --- a/web/modules/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.info.yml +++ b/web/modules/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.info.yml @@ -8,7 +8,7 @@ core_version_requirement: ^8.8.0 || ^9.0 || ^10 dependencies: - admin_toolbar:admin_toolbar -# Information added by Drupal.org packaging script on 2022-01-25 -version: '3.1.0' +# Information added by Drupal.org packaging script on 2022-07-26 +version: '3.1.1' project: 'admin_toolbar' -datestamp: 1643097063 +datestamp: 1658801856 diff --git a/web/modules/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.module b/web/modules/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.module index 616f37e5c1..bb8b1aef54 100755 --- a/web/modules/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.module +++ b/web/modules/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.module @@ -58,6 +58,11 @@ function admin_toolbar_links_access_filter_preprocess_menu(&$variables) { * Hides links from admin menu, if user doesn't have access rights. */ function admin_toolbar_links_access_filter_filter_non_accessible_links(array &$items) { + if (Drupal::currentUser()->id() == 1) { + // Admin can access everything. + return; + } + $access_manager = \Drupal::accessManager(); foreach ($items as $menu_id => &$item) { $route_name = NULL; diff --git a/web/modules/admin_toolbar/admin_toolbar_search/admin_toolbar_search.info.yml b/web/modules/admin_toolbar/admin_toolbar_search/admin_toolbar_search.info.yml index c34964fd7c..dd7d4bab2d 100644 --- a/web/modules/admin_toolbar/admin_toolbar_search/admin_toolbar_search.info.yml +++ b/web/modules/admin_toolbar/admin_toolbar_search/admin_toolbar_search.info.yml @@ -7,7 +7,7 @@ configure: admin_toolbar_search.settings dependencies: - admin_toolbar:admin_toolbar_tools -# Information added by Drupal.org packaging script on 2022-01-25 -version: '3.1.0' +# Information added by Drupal.org packaging script on 2022-07-26 +version: '3.1.1' project: 'admin_toolbar' -datestamp: 1643097063 +datestamp: 1658801856 diff --git a/web/modules/admin_toolbar/admin_toolbar_search/config/schema/admin_toolbar_search.schema.yml b/web/modules/admin_toolbar/admin_toolbar_search/config/schema/admin_toolbar_search.schema.yml index cd398e7474..06f7b76601 100644 --- a/web/modules/admin_toolbar/admin_toolbar_search/config/schema/admin_toolbar_search.schema.yml +++ b/web/modules/admin_toolbar/admin_toolbar_search/config/schema/admin_toolbar_search.schema.yml @@ -4,4 +4,4 @@ admin_toolbar_search.settings: mapping: display_menu_item: type: integer - label: 'How the serach input will be displayed' + label: 'How the search input will be displayed' diff --git a/web/modules/admin_toolbar/admin_toolbar_search/js/admin_toolbar_search.js b/web/modules/admin_toolbar/admin_toolbar_search/js/admin_toolbar_search.js index 0ceca9e804..45ea06d426 100755 --- a/web/modules/admin_toolbar/admin_toolbar_search/js/admin_toolbar_search.js +++ b/web/modules/admin_toolbar/admin_toolbar_search/js/admin_toolbar_search.js @@ -35,7 +35,7 @@ source: function (request, response) { var data = $self.handleAutocomplete(request.term); if (!$self.extraFetched && drupalSettings.adminToolbarSearch.loadExtraLinks) { - $.getJSON( Drupal.url('admin/admin-toolbar-search'), function( data ) { + $.getJSON( Drupal.url('admin/admin-toolbar-search'), function ( data ) { $(data).each(function () { var item = this; item.label = this.labelRaw + ' ' + this.value; diff --git a/web/modules/admin_toolbar/admin_toolbar_search/src/Form/AdminToolbarSearchSettingsForm.php b/web/modules/admin_toolbar/admin_toolbar_search/src/Form/AdminToolbarSearchSettingsForm.php index 1ffb3ea079..3246c19ee4 100644 --- a/web/modules/admin_toolbar/admin_toolbar_search/src/Form/AdminToolbarSearchSettingsForm.php +++ b/web/modules/admin_toolbar/admin_toolbar_search/src/Form/AdminToolbarSearchSettingsForm.php @@ -31,7 +31,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['display_menu_item'] = [ '#type' => 'checkbox', '#title' => $this->t('Display the search input as a menu item.'), - '#description' => $this->t("if set, instead of display a text input field, it's displayed a menu item in the toolbar so the user has to click on it to toggle the search input."), + '#description' => $this->t("If set, instead of displaying a text input field, it displays a menu item in the toolbar so the user has to click on it to toggle the search input."), '#default_value' => $this->config('admin_toolbar_search.settings')->get('display_menu_item'), ]; return parent::buildForm($form, $form_state); diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.info.yml b/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.info.yml index 7bf45be5d3..979b059664 100644 --- a/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.info.yml +++ b/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.info.yml @@ -7,7 +7,7 @@ core_version_requirement: ^8.8.0 || ^9.0 || ^10 dependencies: - admin_toolbar:admin_toolbar -# Information added by Drupal.org packaging script on 2022-01-25 -version: '3.1.0' +# Information added by Drupal.org packaging script on 2022-07-26 +version: '3.1.1' project: 'admin_toolbar' -datestamp: 1643097063 +datestamp: 1658801856 diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.module b/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.module index 17f3dba7fb..4682d6f9c7 100755 --- a/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.module +++ b/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.module @@ -8,6 +8,7 @@ use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Url; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Cache\CacheableMetadata; /** * Implements hook_toolbar(). @@ -24,6 +25,49 @@ function admin_toolbar_tools_toolbar() { ], '#attached' => ['library' => ['admin_toolbar_tools/toolbar.icon']], ]; + + // Toolbar item for primary local tasks. + $config = \Drupal::config('admin_toolbar_tools.settings')->get('show_local_tasks'); + $items['admin_toolbar_local_tasks'] = []; + CacheableMetadata::createFromObject($config)->applyTo($items['admin_toolbar_local_tasks']); + + if ($config) { + $items['admin_toolbar_local_tasks'] += [ + '#type' => 'toolbar_item', + '#wrapper_attributes' => [ + 'class' => ['local-tasks-toolbar-tab'], + ], + // Put it after contextual toolbar item so when float right is applied + // local tasks item will be first. + '#weight' => 10, + 'tab' => [ + // We can't use #lazy_builder here because + // ToolbarItem::preRenderToolbarItem will insert #attributes before + // lazy_builder callback and this will produce Exception. + // This means that for now we always render Local Tasks item even when + // the tray is empty. + '#type' => 'link', + '#title' => t('Local Tasks'), + '#url' => Url::fromRoute('<none>'), + '#attributes' => [ + 'class' => [ + 'toolbar-icon', + 'toolbar-icon-local-tasks', + ], + ], + ], + 'tray' => [ + 'local_links' => [ + '#lazy_builder' => [ + 'admin_toolbar_tools.helper:localTasksTrayLazyBuilder', + [], + ], + ], + ], + '#attached' => ['library' => ['admin_toolbar_tools/toolbar.icon']], + ]; + } + return $items; } diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.services.yml b/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.services.yml index aa533c7871..2e94027a84 100644 --- a/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.services.yml +++ b/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.services.yml @@ -3,3 +3,5 @@ services: class: Drupal\admin_toolbar_tools\AdminToolbarToolsHelper arguments: - '@entity_type.manager' + - '@plugin.manager.menu.local_task' + - '@current_route_match' diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/config/install/admin_toolbar_tools.settings.yml b/web/modules/admin_toolbar/admin_toolbar_tools/config/install/admin_toolbar_tools.settings.yml index 2f4de2018d..72b054e578 100644 --- a/web/modules/admin_toolbar/admin_toolbar_tools/config/install/admin_toolbar_tools.settings.yml +++ b/web/modules/admin_toolbar/admin_toolbar_tools/config/install/admin_toolbar_tools.settings.yml @@ -1,2 +1,3 @@ max_bundle_number: 20 hoverintent_functionality: true +show_local_tasks: false diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/config/schema/admin_toolbar_tools.schema.yml b/web/modules/admin_toolbar/admin_toolbar_tools/config/schema/admin_toolbar_tools.schema.yml index 1280d38fb0..0994a8bcf4 100644 --- a/web/modules/admin_toolbar/admin_toolbar_tools/config/schema/admin_toolbar_tools.schema.yml +++ b/web/modules/admin_toolbar/admin_toolbar_tools/config/schema/admin_toolbar_tools.schema.yml @@ -8,3 +8,6 @@ admin_toolbar_tools.settings: hoverintent_functionality: type: boolean label: 'Enable or disable hoverintent functionality' + show_local_tasks: + type: boolean + label: 'Show local tasks in toolbar' diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/css/tools.css b/web/modules/admin_toolbar/admin_toolbar_tools/css/tools.css index db426ba8ff..188c972f3a 100755 --- a/web/modules/admin_toolbar/admin_toolbar_tools/css/tools.css +++ b/web/modules/admin_toolbar/admin_toolbar_tools/css/tools.css @@ -33,3 +33,15 @@ .toolbar-icon-8 .toolbar-icon-admin-toolbar-tools-help.active:before { background-image: url(../misc/icons/ffffff/drupal-8-logo.svg); } + +.toolbar-oriented .toolbar-bar .local-tasks-toolbar-tab { + float: right; +} + +.toolbar-horizontal .local-tasks-toolbar-tab .toolbar-menu { + float: right; +} + +.toolbar-bar .toolbar-icon-local-tasks:before { + background-image: url(../misc/icons/bebebe/tasks.svg); +} diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/misc/icons/bebebe/tasks.svg b/web/modules/admin_toolbar/admin_toolbar_tools/misc/icons/bebebe/tasks.svg new file mode 100644 index 0000000000..2eabb5dad1 --- /dev/null +++ b/web/modules/admin_toolbar/admin_toolbar_tools/misc/icons/bebebe/tasks.svg @@ -0,0 +1,4 @@ +<svg fill="#bebebe" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"> + <path d="M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"/> + <path d="M0 0h24v24H0V0z" fill="none"/> +</svg> diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/src/AdminToolbarToolsHelper.php b/web/modules/admin_toolbar/admin_toolbar_tools/src/AdminToolbarToolsHelper.php index b270e679e9..7a518991c1 100644 --- a/web/modules/admin_toolbar/admin_toolbar_tools/src/AdminToolbarToolsHelper.php +++ b/web/modules/admin_toolbar/admin_toolbar_tools/src/AdminToolbarToolsHelper.php @@ -3,11 +3,15 @@ namespace Drupal\admin_toolbar_tools; use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\Menu\LocalTaskManager; +use Drupal\Core\Render\Element; +use Drupal\Core\Routing\RouteMatchInterface; +use Drupal\Core\Security\TrustedCallbackInterface; /** * Admin Toolbar Tools helper service. */ -class AdminToolbarToolsHelper { +class AdminToolbarToolsHelper implements TrustedCallbackInterface { /** * The entity type manager. @@ -16,14 +20,73 @@ class AdminToolbarToolsHelper { */ protected $entityTypeManager; + /** + * The local task manger. + * + * @var \Drupal\Core\Menu\LocalTaskManager + * The local task manager menu. + */ + protected $localTaskManager; + + /** + * The route match interface. + * + * @var \Drupal\Core\Routing\RouteMatchInterface + * The route match. + */ + protected $routeMatch; + /** * Create an AdminToolbarToolsHelper object. * * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. + * @param \Drupal\Core\Menu\LocalTaskManager $local_task_manager + * The local task manager. + * @param \Drupal\Core\Routing\RouteMatchInterface $route_match + * The route match. */ - public function __construct(EntityTypeManagerInterface $entity_type_manager) { + public function __construct(EntityTypeManagerInterface $entity_type_manager, LocalTaskManager $local_task_manager, RouteMatchInterface $route_match) { $this->entityTypeManager = $entity_type_manager; + $this->localTaskManager = $local_task_manager; + $this->routeMatch = $route_match; + } + + /** + * {@inheritdoc} + */ + public static function trustedCallbacks() { + return ['localTasksTrayLazyBuilder']; + } + + /** + * Lazy builder callback for the admin_toolbar_local_tasks tray items. + * + * @return array + * A renderable array as expected by the renderer service. + */ + public function localTasksTrayLazyBuilder() { + // Get primary local task links and inject them into new + // admin_toolbar_local_tasks toolbar tray. + $links = $this->localTaskManager->getLocalTasks($this->routeMatch->getRouteName(), 0); + if (!empty($links['tabs'])) { + $build = [ + '#theme' => 'links', + '#links' => [], + '#attributes' => [ + 'class' => ['toolbar-menu'], + ], + ]; + Element::children($links['tabs'], TRUE); + $routes = Element::getVisibleChildren($links['tabs']); + foreach ($routes as $route) { + $build['#links'][$route] = $links['tabs'][$route]['#link']; + } + $links['cacheability']->applyTo($build); + return $build; + } + + return []; } /** diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/src/Form/AdminToolbarToolsSettingsForm.php b/web/modules/admin_toolbar/admin_toolbar_tools/src/Form/AdminToolbarToolsSettingsForm.php index 6463bdf729..6d798caf7c 100644 --- a/web/modules/admin_toolbar/admin_toolbar_tools/src/Form/AdminToolbarToolsSettingsForm.php +++ b/web/modules/admin_toolbar/admin_toolbar_tools/src/Form/AdminToolbarToolsSettingsForm.php @@ -92,6 +92,13 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#default_value' => $config->get('hoverintent_functionality'), ]; + $form['show_local_tasks'] = [ + '#type' => 'checkbox', + '#title' => $this->t('Enable/Disable local tasks display'), + '#description' => $this->t('Local tasks such as node edit and delete.'), + '#default_value' => $config->get('show_local_tasks'), + ]; + return parent::buildForm($form, $form_state); } @@ -102,6 +109,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('admin_toolbar_tools.settings') ->set('max_bundle_number', $form_state->getValue('max_bundle_number')) ->set('hoverintent_functionality', $form_state->getValue('hoverintent_functionality')) + ->set('show_local_tasks', $form_state->getValue('show_local_tasks')) ->save(); parent::submitForm($form, $form_state); $this->cacheMenu->invalidateAll(); diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php b/web/modules/admin_toolbar/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php index 70a49526dd..358263a383 100755 --- a/web/modules/admin_toolbar/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php +++ b/web/modules/admin_toolbar/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php @@ -218,12 +218,6 @@ public function getDerivativeDefinitions($base_plugin_definition) { 'route_name' => 'entity.user_role.collection', 'parent' => 'entity.user.collection', ] + $base_plugin_definition; - $links['user.logout'] = [ - 'title' => $this->t('Logout'), - 'route_name' => 'user.logout', - 'parent' => 'admin_toolbar_tools.help', - 'weight' => 10, - ] + $base_plugin_definition; $links['user.role_add'] = [ 'title' => $this->t('Add role'), 'route_name' => 'user.role_add', @@ -376,7 +370,14 @@ public function getDerivativeDefinitions($base_plugin_definition) { 'route_parameters' => ['menu' => $menu_id], ] + $base_plugin_definition; // Un-deletable menus. - $un_deletable_menus = ['admin', 'devel', 'footer', 'main', 'tools', 'account']; + $un_deletable_menus = [ + 'admin', + 'devel', + 'footer', + 'main', + 'tools', + 'account', + ]; if (!in_array($menu_id, $un_deletable_menus)) { $links['entity.menu.delete_form.' . $menu_id] = [ 'title' => $this->t('Delete'), diff --git a/web/modules/admin_toolbar/css/admin.toolbar.css b/web/modules/admin_toolbar/css/admin.toolbar.css index a04b172125..98550bfef2 100755 --- a/web/modules/admin_toolbar/css/admin.toolbar.css +++ b/web/modules/admin_toolbar/css/admin.toolbar.css @@ -65,7 +65,7 @@ display: block; position: absolute; width: 200px; - box-shadow: 2px 2px 3px hsla(0, 0, 0, 0.4); + box-shadow: 2px 2px 3px hsla(0, 0%, 0%, 0.4); z-index: 1; } @@ -178,7 +178,7 @@ display: block; position: absolute; width: 200px; - box-shadow: 2px 2px 3px hsla(0, 0, 0, 0.4); + box-shadow: 2px 2px 3px hsla(0, 0%, 0%, 0.4); z-index: 1; } diff --git a/web/modules/admin_toolbar/js/admin_toolbar.js b/web/modules/admin_toolbar/js/admin_toolbar.js index 6e2a7af171..a714c6efbf 100755 --- a/web/modules/admin_toolbar/js/admin_toolbar.js +++ b/web/modules/admin_toolbar/js/admin_toolbar.js @@ -36,7 +36,8 @@ }); // Always hide the dropdown menu on mobile. - if ($('body:not(.toolbar-fixed) #toolbar-item-administration-tray').hasClass('toolbar-tray-vertical')) { + if (window.matchMedia("(max-width: 767px)").matches && $('body').hasClass('toolbar-tray-open')) { + $('body').removeClass('toolbar-tray-open'); $('#toolbar-item-administration').removeClass('is-active'); $('#toolbar-item-administration-tray').removeClass('is-active'); }; diff --git a/web/modules/admin_toolbar/src/Render/Element/AdminToolbar.php b/web/modules/admin_toolbar/src/Render/Element/AdminToolbar.php index 33f4604c77..187db02981 100644 --- a/web/modules/admin_toolbar/src/Render/Element/AdminToolbar.php +++ b/web/modules/admin_toolbar/src/Render/Element/AdminToolbar.php @@ -38,7 +38,7 @@ public static function preRenderTray(array $build) { $parameters = new MenuTreeParameters(); $max_depth = \Drupal::config('admin_toolbar.settings')->get('menu_depth'); $parameters->setRoot('system.admin')->excludeRoot()->setMaxDepth($max_depth)->onlyEnabledLinks(); - $tree = $menu_tree->load(NULL, $parameters); + $tree = $menu_tree->load('admin', $parameters); $manipulators = [ ['callable' => 'menu.default_tree_manipulators:checkAccess'], ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'], diff --git a/web/modules/admin_toolbar/tests/src/Functional/AdminToolbarAdminMenuTest.php b/web/modules/admin_toolbar/tests/src/Functional/AdminToolbarAdminMenuTest.php new file mode 100644 index 0000000000..7e9b4f9c07 --- /dev/null +++ b/web/modules/admin_toolbar/tests/src/Functional/AdminToolbarAdminMenuTest.php @@ -0,0 +1,23 @@ +<?php + +namespace Drupal\Tests\admin_toolbar\Functional; + +use Drupal\Tests\toolbar\Functional\ToolbarAdminMenuTest; + +/** + * Tests the caching of the admin menu subtree items. + * + * @group admin_toolbar + */ +class AdminToolbarAdminMenuTest extends ToolbarAdminMenuTest { + + /** + * Modules to enable. + * + * @var array + */ + protected static $modules = [ + 'admin_toolbar', + ]; + +} -- GitLab