Commit 192fe948 authored by Len Swaneveld's avatar Len Swaneveld Committed by Emil Stjerneman
Browse files

Issue #3108030 by Lendude, anon: Media links with standalone_url on are broken

parent 63e545bd
......@@ -497,7 +497,7 @@ class EntityMatcher extends ConfigurableMatcherBase {
// by $entity->toUrl().
if ($entity->getEntityTypeId() == 'media') {
$standalone_url = \Drupal::config('media.settings')->get('standalone_url');
if ($standalone_url) {
if (!$standalone_url) {
// Strip "/edit".
$path = substr($path, 0, -5);
}
......
......@@ -36,6 +36,7 @@ class MediaMatcherTest extends LinkitKernelTestBase {
$this->installEntitySchema('file');
$this->installEntitySchema('media');
$this->installConfig(['media']);
$this->installSchema('system', ['key_value_expire']);
$this->installSchema('file', ['file_usage']);
......@@ -89,16 +90,17 @@ class MediaMatcherTest extends LinkitKernelTestBase {
// Verify suggestion paths.
foreach ($suggestions->getSuggestions() as $key => $suggestion) {
$this->assertEquals('/media/' . ($key + 1) . '/edit', $suggestion->getPath());
$this->assertEquals('/media/' . ($key + 1), $suggestion->getPath());
}
// Enable stand-alone URLs for media entities.
$config = \Drupal::service('config.factory')->getEditable('media.settings');
$config->set('standalone_url', TRUE)->save();
drupal_flush_all_caches();
$suggestions = $plugin->execute('image-test');
// Re-verify suggestion paths.
// Re-verify suggestion paths, they should not contain /edit.
foreach ($suggestions->getSuggestions() as $key => $suggestion) {
$this->assertEquals('/media/' . ($key + 1), $suggestion->getPath());
}
......
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