Skip to content
Snippets Groups Projects
Commit 571be2c4 authored by Marc Wolf's avatar Marc Wolf Committed by Marcos Cano
Browse files

Issue #3514883 by m4rcw0lf, kevinb623, marcoscano: Assertion fails when using...

Issue #3514883 by m4rcw0lf, kevinb623, marcoscano: Assertion fails when using external stream wrappers (e.g. s3fs) in PublicFileIntegration
parent 38a9f02e
No related branches found
No related tags found
1 merge request!131fix(entity_usage): Support external stream wrappers (e.g., s3fs) in entity_usage by using getExternalUrl()
Pipeline #464819 failed
......@@ -3,7 +3,6 @@
namespace Drupal\entity_usage\UrlToEntityIntegrations;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\StreamWrapper\LocalStream;
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
use Drupal\entity_usage\Events\Events;
use Drupal\entity_usage\Events\UrlToEntityEvent;
......@@ -25,8 +24,16 @@ class PublicFileIntegration implements EventSubscriberInterface {
#[Autowire(service: 'stream_wrapper.public')]
StreamWrapperInterface $publicStream,
) {
assert($publicStream instanceof LocalStream);
$this->publicFilePattern = '{^/?' . $publicStream->getDirectoryPath() . '/}';
$baseUrl = $publicStream->getExternalUrl();
$parsed = parse_url($baseUrl);
if (isset($parsed['path'])) {
$this->publicFilePattern = '{^' . preg_quote($parsed['path'], '{}') . '/}';
}
else {
throw new \LogicException('The public stream wrapper does not provide a valid external URL.');
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment