OpenCommand.php 728 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * @file
  4. * Contains \Drupal\colorbox_load\OpenCommand.
  5. */
  6. namespace Drupal\colorbox_load;
  7. use Drupal\Core\Ajax\CommandInterface;
  8. /**
  9. * Defines an AJAX command to open content in a colorbox.
  10. */
  11. class OpenCommand implements CommandInterface {
  12. /**
  13. * The content for the colorbox.
  14. *
  15. * @var string
  16. */
  17. protected $content;
  18. /**
  19. * Constructs an OpenCommand object.
  20. *
  21. * @param string $content
  22. * The content that will be placed in the colorbox.
  23. */
  24. public function __construct($content) {
  25. $this->content = $content;
  26. }
  27. /**
  28. * {@inheritdoc{
  29. */
  30. public function render() {
  31. return [
  32. 'command' => 'colorboxLoadOpen',
  33. 'data' => $this->content,
  34. ];
  35. }
  36. }