Commit 0770fbc0 authored by Adam Bramley's avatar Adam Bramley Committed by Emil Stjerneman
Browse files

Issue #3069481 by acbramley, pingevt, anon: "Direct URL to media file entity"...

Issue #3069481 by acbramley, pingevt, anon: "Direct URL to media file entity" broken in latest update
parent b529e61d
......@@ -50,6 +50,7 @@ class Media extends PluginBase implements SubstitutionInterface, ContainerFactor
$file = $entity->get($source_field->getName())->entity;
$url->setGeneratedUrl(file_create_url($file->getFileUri()));
$url->addCacheableDependency($entity);
return $url;
}
// If available, fall back to the canonical URL if the bundle doesn't have
......
......@@ -170,7 +170,13 @@ class SubstitutionPluginTest extends LinkitKernelTestBase {
$media->save();
$media_substitution = $this->substitutionManager->createInstance('media');
$this->assertEquals($GLOBALS['base_url'] . '/' . $this->siteDirectory . '/files/druplicon.txt', $media_substitution->getUrl($media)->getGeneratedUrl());
$expected = $GLOBALS['base_url'] . '/' . $this->siteDirectory . '/files/druplicon.txt';
$this->assertEquals($expected, $media_substitution->getUrl($media)->getGeneratedUrl());
// Ensure the url is identical when media entities have a standalone URL
// enabled.
\Drupal::configFactory()->getEditable('media.settings')->set('standalone_url', TRUE)->save();
$this->assertEquals($expected, $media_substitution->getUrl($media)->getGeneratedUrl());
$entity_type = $this->entityTypeManager->getDefinition('media');
$this->assertTrue(MediaSubstitutionPlugin::isApplicable($entity_type), 'The entity type Media is applicable the media substitution.');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment