diff core/modules/media_library/src/Ajax/UpdateSelectionCommand.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/modules/media_library/src/Ajax/UpdateSelectionCommand.php	Thu May 09 15:34:47 2019 +0100
@@ -0,0 +1,54 @@
+<?php
+
+namespace Drupal\media_library\Ajax;
+
+use Drupal\Core\Ajax\CommandInterface;
+
+/**
+ * AJAX command for adding media items to the media library selection.
+ *
+ * This command instructs the client to add the given media item IDs to the
+ * current selection of the media library stored in
+ * Drupal.MediaLibrary.currentSelection.
+ *
+ * This command is implemented by
+ * Drupal.AjaxCommands.prototype.updateMediaLibrarySelection() defined in
+ * media_library.ui.js.
+ *
+ * @ingroup ajax
+ *
+ * @internal
+ *   Media Library is an experimental module and its internal code may be
+ *   subject to change in minor releases. External code should not instantiate
+ *   or extend this class.
+ */
+class UpdateSelectionCommand implements CommandInterface {
+
+  /**
+   * An array of media IDs to add to the current selection.
+   *
+   * @var int[]
+   */
+  protected $mediaIds;
+
+  /**
+   * Constructs an UpdateSelectionCommand object.
+   *
+   * @param int[] $media_ids
+   *   An array of media IDs to add to the current selection.
+   */
+  public function __construct(array $media_ids) {
+    $this->mediaIds = $media_ids;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function render() {
+    return [
+      'command' => 'updateMediaLibrarySelection',
+      'mediaIds' => $this->mediaIds,
+    ];
+  }
+
+}