summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxjm2018-01-08 14:31:34 (GMT)
committerxjm2018-01-08 14:31:34 (GMT)
commit1da5a5ccb31a844127998907dddd76667a2bc16c (patch)
tree19cea5492d38e66aac17bf447ff943a5563abfea
parentd039f07cb758f7350c6e8f5643c3182944472271 (diff)
Issue #2775131 by chr.fritsch, marcoscano, katzilla, seanB, xjm, gippy, phenaproxima, alexpott, Berdir, lauriii, webflo, dawehner: Media entities should support contextual links
-rw-r--r--core/modules/media/templates/media.html.twig5
-rw-r--r--core/modules/media/tests/src/Functional/MediaContextualLinksTest.php45
-rw-r--r--core/themes/classy/templates/content/media.html.twig5
-rw-r--r--core/themes/stable/templates/content/media.html.twig5
4 files changed, 60 insertions, 0 deletions
diff --git a/core/modules/media/templates/media.html.twig b/core/modules/media/templates/media.html.twig
index 28c0a83..6b3d6b3 100644
--- a/core/modules/media/templates/media.html.twig
+++ b/core/modules/media/templates/media.html.twig
@@ -26,11 +26,16 @@
* - title_attributes: Same as attributes, except applied to the main title
* tag that appears in the template.
*
+ * Note that we print {{ title_suffix }} even though the title is not included.
+ * This is intentional, once contextual links are embedded in the "title_suffix"
+ * variable. See #2775131 for more information on the background about this.
+ *
* @see template_preprocess_media()
*
* @ingroup themeable
*/
#}
<div{{ attributes }}>
+ {{ title_suffix }}
{{ content }}
</div>
diff --git a/core/modules/media/tests/src/Functional/MediaContextualLinksTest.php b/core/modules/media/tests/src/Functional/MediaContextualLinksTest.php
new file mode 100644
index 0000000..1d97773
--- /dev/null
+++ b/core/modules/media/tests/src/Functional/MediaContextualLinksTest.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Drupal\Tests\media\Functional;
+
+use Drupal\media\Entity\Media;
+
+/**
+ * Tests views contextual links on media items.
+ *
+ * @group media
+ */
+class MediaContextualLinksTest extends MediaFunctionalTestBase {
+
+ /**
+ * {@inheritdoc}
+ */
+ public static $modules = [
+ 'contextual',
+ ];
+
+ /**
+ * Tests contextual links.
+ */
+ public function testMediaContextualLinks() {
+ // Create a media type.
+ $mediaType = $this->createMediaType();
+
+ // Create a media item.
+ $media = Media::create([
+ 'bundle' => $mediaType->id(),
+ 'name' => 'Unnamed',
+ ]);
+ $media->save();
+
+ $user = $this->drupalCreateUser([
+ 'administer media',
+ 'access contextual links',
+ ]);
+ $this->drupalLogin($user);
+
+ $this->drupalGet('media/' . $media->id());
+ $this->assertSession()->elementAttributeContains('css', 'div[data-contextual-id]', 'data-contextual-id', 'media:media=' . $media->id() . ':');
+ }
+
+}
diff --git a/core/themes/classy/templates/content/media.html.twig b/core/themes/classy/templates/content/media.html.twig
index f36975c..6728367 100644
--- a/core/themes/classy/templates/content/media.html.twig
+++ b/core/themes/classy/templates/content/media.html.twig
@@ -7,6 +7,10 @@
* - name: Name of the media.
* - content: Media content.
*
+ * Note that we print {{ title_suffix }} even though the title is not included.
+ * This is intentional, once contextual links are embedded in the "title_suffix"
+ * variable. See #2775131 for more information on the background about this.
+ *
* @see template_preprocess_media()
*
* @ingroup themeable
@@ -21,6 +25,7 @@
]
%}
<article{{ attributes.addClass(classes) }}>
+ {{ title_suffix }}
{% if content %}
{{ content }}
{% endif %}
diff --git a/core/themes/stable/templates/content/media.html.twig b/core/themes/stable/templates/content/media.html.twig
index 769b7be..cecaac8 100644
--- a/core/themes/stable/templates/content/media.html.twig
+++ b/core/themes/stable/templates/content/media.html.twig
@@ -7,12 +7,17 @@
* - name: Name of the media.
* - content: Media content.
*
+ * Note that we print {{ title_suffix }} even though the title is not included.
+ * This is intentional, once contextual links are embedded in the "title_suffix"
+ * variable. See #2775131 for more information on the background about this.
+ *
* @see template_preprocess_media()
*
* @ingroup themeable
*/
#}
<article{{ attributes }}>
+ {{ title_suffix }}
{% if content %}
{{ content }}
{% endif %}