Loading core/modules/file/tests/file_test/file_test.routing.yml +14 −0 Original line number Diff line number Diff line Loading @@ -16,3 +16,17 @@ file.required_test: _form: '\Drupal\file_test\Form\FileRequiredTestForm' requirements: _access: 'TRUE' file_test.dummy: path: '/system/dummy' defaults: _controller: '\Drupal\system\FileDownloadController::download' scheme: dummy-private requirements: _access: 'TRUE' file_test.public: path: '/system/dummy-public' defaults: _controller: '\Drupal\system\FileDownloadController::download' scheme: dummy-public requirements: _access: 'TRUE' core/modules/file/tests/file_test/file_test.services.yml +8 −0 Original line number Diff line number Diff line Loading @@ -22,5 +22,13 @@ services: tags: - { name: stream_wrapper, scheme: dummy1 } - { name: stream_wrapper, scheme: dummy2 } stream_wrapper.dummy_private: class: Drupal\file_test\StreamWrapper\DummyPrivateStreamWrapper tags: - { name: stream_wrapper, scheme: dummy-private } stream_wrapper.dummy_public: class: Drupal\file_test\StreamWrapper\DummyPublicStreamWrapper tags: - { name: stream_wrapper, scheme: dummy-public } Drupal\file_test\EventSubscriber\DummyMimeTypeMapLoadedSubscriber: autowire: true core/modules/file/tests/file_test/src/Hook/FileTestHooks.php +8 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,14 @@ public function fileDownload($uri): array|int|null { $file = reset($files); return $file->getDownloadHeaders(); } if (\Drupal::keyValue('file_test')->get('file_test_active_stream_wrapper') === 'dummy-private') { return ['Cache-Control' => 'private']; } if (\Drupal::keyValue('file_test')->get('file_test_active_stream_wrapper') === 'dummy-public') { return ['Cache-Control' => 'public']; } FileTestHelper::logCall('download', [$uri]); return $this->getReturn('download'); } Loading core/modules/file/tests/file_test/src/StreamWrapper/DummyPrivateStreamWrapper.php 0 → 100644 +28 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\file_test\StreamWrapper; use Drupal\Core\Url; /** * Helper class for testing the stream wrapper registry. * * Dummy stream wrapper implementation (dummy-private://). */ class DummyPrivateStreamWrapper extends DummyStreamWrapper { /** * {@inheritdoc} */ public function getExternalUrl(): string { $path = str_replace('\\', '/', $this->getTarget()); return Url::fromRoute( 'file_test.dummy', ['filepath' => $path], ['absolute' => TRUE, 'path_processing' => FALSE, 'query' => ['file' => $path]] )->toString(); } } core/modules/file/tests/file_test/src/StreamWrapper/DummyPublicStreamWrapper.php 0 → 100644 +28 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\file_test\StreamWrapper; use Drupal\Core\Url; /** * Helper class for testing the stream wrapper registry. * * Dummy stream wrapper implementation (dummy-public://). */ class DummyPublicStreamWrapper extends DummyStreamWrapper { /** * {@inheritdoc} */ public function getExternalUrl(): string { $path = str_replace('\\', '/', $this->getTarget()); return Url::fromRoute( 'file_test.public', ['filepath' => $path], ['absolute' => TRUE, 'path_processing' => FALSE, 'query' => ['file' => $path]] )->toString(); } } Loading
core/modules/file/tests/file_test/file_test.routing.yml +14 −0 Original line number Diff line number Diff line Loading @@ -16,3 +16,17 @@ file.required_test: _form: '\Drupal\file_test\Form\FileRequiredTestForm' requirements: _access: 'TRUE' file_test.dummy: path: '/system/dummy' defaults: _controller: '\Drupal\system\FileDownloadController::download' scheme: dummy-private requirements: _access: 'TRUE' file_test.public: path: '/system/dummy-public' defaults: _controller: '\Drupal\system\FileDownloadController::download' scheme: dummy-public requirements: _access: 'TRUE'
core/modules/file/tests/file_test/file_test.services.yml +8 −0 Original line number Diff line number Diff line Loading @@ -22,5 +22,13 @@ services: tags: - { name: stream_wrapper, scheme: dummy1 } - { name: stream_wrapper, scheme: dummy2 } stream_wrapper.dummy_private: class: Drupal\file_test\StreamWrapper\DummyPrivateStreamWrapper tags: - { name: stream_wrapper, scheme: dummy-private } stream_wrapper.dummy_public: class: Drupal\file_test\StreamWrapper\DummyPublicStreamWrapper tags: - { name: stream_wrapper, scheme: dummy-public } Drupal\file_test\EventSubscriber\DummyMimeTypeMapLoadedSubscriber: autowire: true
core/modules/file/tests/file_test/src/Hook/FileTestHooks.php +8 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,14 @@ public function fileDownload($uri): array|int|null { $file = reset($files); return $file->getDownloadHeaders(); } if (\Drupal::keyValue('file_test')->get('file_test_active_stream_wrapper') === 'dummy-private') { return ['Cache-Control' => 'private']; } if (\Drupal::keyValue('file_test')->get('file_test_active_stream_wrapper') === 'dummy-public') { return ['Cache-Control' => 'public']; } FileTestHelper::logCall('download', [$uri]); return $this->getReturn('download'); } Loading
core/modules/file/tests/file_test/src/StreamWrapper/DummyPrivateStreamWrapper.php 0 → 100644 +28 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\file_test\StreamWrapper; use Drupal\Core\Url; /** * Helper class for testing the stream wrapper registry. * * Dummy stream wrapper implementation (dummy-private://). */ class DummyPrivateStreamWrapper extends DummyStreamWrapper { /** * {@inheritdoc} */ public function getExternalUrl(): string { $path = str_replace('\\', '/', $this->getTarget()); return Url::fromRoute( 'file_test.dummy', ['filepath' => $path], ['absolute' => TRUE, 'path_processing' => FALSE, 'query' => ['file' => $path]] )->toString(); } }
core/modules/file/tests/file_test/src/StreamWrapper/DummyPublicStreamWrapper.php 0 → 100644 +28 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\file_test\StreamWrapper; use Drupal\Core\Url; /** * Helper class for testing the stream wrapper registry. * * Dummy stream wrapper implementation (dummy-public://). */ class DummyPublicStreamWrapper extends DummyStreamWrapper { /** * {@inheritdoc} */ public function getExternalUrl(): string { $path = str_replace('\\', '/', $this->getTarget()); return Url::fromRoute( 'file_test.public', ['filepath' => $path], ['absolute' => TRUE, 'path_processing' => FALSE, 'query' => ['file' => $path]] )->toString(); } }