Version 1
[yaffs-website] / web / modules / contrib / entity_browser / src / WidgetsLazyPluginCollection.php
diff --git a/web/modules/contrib/entity_browser/src/WidgetsLazyPluginCollection.php b/web/modules/contrib/entity_browser/src/WidgetsLazyPluginCollection.php
new file mode 100644 (file)
index 0000000..875dd93
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+namespace Drupal\entity_browser;
+
+use Drupal\Core\Plugin\DefaultLazyPluginCollection;
+
+/**
+ * A collection of entity browser widgets.
+ */
+class WidgetsLazyPluginCollection extends DefaultLazyPluginCollection {
+
+  /**
+   * Provides uasort() callback to sort plugins.
+   */
+  public function sortHelper($a, $b) {
+    $weight_a = $this->get($a)->getWeight();
+    $weight_b = $this->get($b)->getWeight();
+
+    return $weight_a < $weight_b ? -1 : 1;
+  }
+
+}