You are here

OpenCommand.php in Colorbox Load 8

File

src/OpenCommand.php
View source
<?php

namespace Drupal\colorbox_load;

use Drupal\Core\Ajax\CommandInterface;

/**
 * Defines an AJAX command to open content in a colorbox.
 */
class OpenCommand implements CommandInterface {

  /**
   * The content for the colorbox.
   *
   * @var string
   */
  protected $content;

  /**
   * Constructs an OpenCommand object.
   *
   * @param string $content
   *   The content that will be placed in the colorbox.
   */
  public function __construct($content) {
    $this->content = $content;
  }

  /**
   * Render.
   *
   * {@inheritdoc}.
   */
  public function render() {
    return [
      'command' => 'colorboxLoadOpen',
      'data' => $this->content,
    ];
  }

}

Classes

Namesort descending Description
OpenCommand Defines an AJAX command to open content in a colorbox.