RedirectCommand.php 726 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Drupal\Core\Ajax;
  3. /**
  4. * Defines an AJAX command to set the window.location, loading that URL.
  5. *
  6. * @ingroup ajax
  7. */
  8. class RedirectCommand implements CommandInterface {
  9. /**
  10. * The URL that will be loaded into window.location.
  11. *
  12. * @var string
  13. */
  14. protected $url;
  15. /**
  16. * Constructs an RedirectCommand object.
  17. *
  18. * @param string $url
  19. * The URL that will be loaded into window.location. This should be a full
  20. * URL.
  21. */
  22. public function __construct($url) {
  23. $this->url = $url;
  24. }
  25. /**
  26. * Implements \Drupal\Core\Ajax\CommandInterface:render().
  27. */
  28. public function render() {
  29. return [
  30. 'command' => 'redirect',
  31. 'url' => $this->url,
  32. ];
  33. }
  34. }