Version 1
[yaffs-website] / web / core / modules / views / src / Plugin / views / field / Dropbutton.php
diff --git a/web/core/modules/views/src/Plugin/views/field/Dropbutton.php b/web/core/modules/views/src/Plugin/views/field/Dropbutton.php
new file mode 100644 (file)
index 0000000..b5a9b60
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+namespace Drupal\views\Plugin\views\field;
+
+use Drupal\views\ResultRow;
+
+/**
+ * Provides a handler that renders links as dropbutton.
+ *
+ * @ingroup views_field_handlers
+ *
+ * @ViewsField("dropbutton")
+ */
+class Dropbutton extends Links {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function render(ResultRow $values) {
+    $links = $this->getLinks();
+
+    if (!empty($links)) {
+      return [
+        '#type' => 'dropbutton',
+        '#links' => $links,
+      ];
+    }
+    else {
+      return '';
+    }
+  }
+
+}