RestripeCommand.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Drupal\Core\Ajax;
  3. /**
  4. * AJAX command for resetting the striping on a table.
  5. *
  6. * The 'restripe' command instructs the client to restripe a table. This is
  7. * usually used after a table has been modified by a replace or append command.
  8. *
  9. * This command is implemented by Drupal.AjaxCommands.prototype.restripe()
  10. * defined in misc/ajax.js.
  11. *
  12. * @ingroup ajax
  13. */
  14. class RestripeCommand implements CommandInterface {
  15. /**
  16. * A CSS selector string.
  17. *
  18. * If the command is a response to a request from an #ajax form element then
  19. * this value can be NULL.
  20. *
  21. * @var string
  22. */
  23. protected $selector;
  24. /**
  25. * Constructs a RestripeCommand object.
  26. *
  27. * @param string $selector
  28. * A CSS selector for the table to be restriped.
  29. */
  30. public function __construct($selector) {
  31. $this->selector = $selector;
  32. }
  33. /**
  34. * Implements Drupal\Core\Ajax\CommandInterface:render().
  35. */
  36. public function render() {
  37. return [
  38. 'command' => 'restripe',
  39. 'selector' => $this->selector,
  40. ];
  41. }
  42. }