annotate 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
rev   line source
Chris@5 1 <?php
Chris@5 2
Chris@5 3 namespace Drupal\media_library\Ajax;
Chris@5 4
Chris@5 5 use Drupal\Core\Ajax\CommandInterface;
Chris@5 6
Chris@5 7 /**
Chris@5 8 * AJAX command for adding media items to the media library selection.
Chris@5 9 *
Chris@5 10 * This command instructs the client to add the given media item IDs to the
Chris@5 11 * current selection of the media library stored in
Chris@5 12 * Drupal.MediaLibrary.currentSelection.
Chris@5 13 *
Chris@5 14 * This command is implemented by
Chris@5 15 * Drupal.AjaxCommands.prototype.updateMediaLibrarySelection() defined in
Chris@5 16 * media_library.ui.js.
Chris@5 17 *
Chris@5 18 * @ingroup ajax
Chris@5 19 *
Chris@5 20 * @internal
Chris@5 21 * Media Library is an experimental module and its internal code may be
Chris@5 22 * subject to change in minor releases. External code should not instantiate
Chris@5 23 * or extend this class.
Chris@5 24 */
Chris@5 25 class UpdateSelectionCommand implements CommandInterface {
Chris@5 26
Chris@5 27 /**
Chris@5 28 * An array of media IDs to add to the current selection.
Chris@5 29 *
Chris@5 30 * @var int[]
Chris@5 31 */
Chris@5 32 protected $mediaIds;
Chris@5 33
Chris@5 34 /**
Chris@5 35 * Constructs an UpdateSelectionCommand object.
Chris@5 36 *
Chris@5 37 * @param int[] $media_ids
Chris@5 38 * An array of media IDs to add to the current selection.
Chris@5 39 */
Chris@5 40 public function __construct(array $media_ids) {
Chris@5 41 $this->mediaIds = $media_ids;
Chris@5 42 }
Chris@5 43
Chris@5 44 /**
Chris@5 45 * {@inheritdoc}
Chris@5 46 */
Chris@5 47 public function render() {
Chris@5 48 return [
Chris@5 49 'command' => 'updateMediaLibrarySelection',
Chris@5 50 'mediaIds' => $this->mediaIds,
Chris@5 51 ];
Chris@5 52 }
Chris@5 53
Chris@5 54 }