ChangedCommand.php

Definition of Drupal\Core\Ajax\ChangedCommand.

Namespace

Drupal\Core\Ajax

File

drupal/core/lib/Drupal/Core/Ajax/ChangedCommand.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of Drupal\Core\Ajax\ChangedCommand.
  5. */
  6. namespace Drupal\Core\Ajax;
  7. use Drupal\Core\Ajax\CommandInterface;
  8. /**
  9. * An AJAX command for marking HTML elements as changed.
  10. *
  11. * This command instructs the client to mark each of the elements matched by the
  12. * given selector as 'ajax-changed'.
  13. *
  14. * This command is implemented by Drupal.AjaxCommands.prototype.changed()
  15. * defined in misc/ajax.js.
  16. */
  17. class ChangedCommand implements CommandInterface {
  18. /**
  19. * A CSS selector string.
  20. *
  21. * If the command is a response to a request from an #ajax form element then
  22. * this value can be NULL.
  23. *
  24. * @var string
  25. */
  26. protected $selector;
  27. /**
  28. * An optional CSS selector for elements to which asterisks will be appended.
  29. *
  30. * @var string
  31. */
  32. protected $asterisk;
  33. /**
  34. * Constructs a ChangedCommand object.
  35. *
  36. * @param string $selector
  37. * CSS selector for elements to be marked as changed.
  38. * @param string $asterisk
  39. * CSS selector for elements to which an asterisk will be appended.
  40. */
  41. public function __construct($selector, $asterisk = '') {
  42. $this->selector = $selector;
  43. $this->asterisk = $asterisk;
  44. }
  45. /**
  46. * Implements Drupal\Core\Ajax\CommandInterface:render().
  47. */
  48. public function render() {
  49. return array(
  50. 'command' => 'changed',
  51. 'selector' => $this->selector,
  52. 'asterisk' => $this->asterisk,
  53. );
  54. }
  55. }

Classes

Namesort descending Description
ChangedCommand An AJAX command for marking HTML elements as changed.