You are here

class CourierTemplate in Courier 8

Same name and namespace in other branches
  1. 2.x src/Ajax/CourierTemplate.php \Drupal\courier\Ajax\CourierTemplate

Defines a CourierTemplate AJAX command.

Command is received by `Drupal.AjaxCommands.prototype.courierTemplate`

Hierarchy

Expanded class hierarchy of CourierTemplate

2 files declare their use of CourierTemplate
ChannelFormController.php in src/Controller/ChannelFormController.php
TemplateEditForm.php in src/Form/TemplateEditForm.php

File

src/Ajax/CourierTemplate.php, line 12

Namespace

Drupal\courier\Ajax
View source
class CourierTemplate implements CommandInterface {

  /**
   * A template collection entity ID.
   *
   * @var int
   */
  protected $template_collection;

  /**
   * Channel entity type ID.
   *
   * @var string
   */
  protected $channel;

  /**
   * Operation to execute on client.
   *
   * @var string
   */
  protected $operation;

  /**
   * Constructs a \Drupal\courier\Ajax\CourierTemplate object.
   *
   * @param int $template_collection
   *   A template collection entity ID.
   * @param string $channel
   *   Channel entity type ID.
   * @param string $operation
   *   Operation to execute on client. Allowed values: 'open', 'close'.
   */
  public function __construct($template_collection, $channel, $operation) {
    $this->template_collection = $template_collection;
    $this->channel = $channel;
    $this->operation = $operation;
  }

  /**
   * Implements \Drupal\Core\Ajax\CommandInterface::render().
   */
  public function render() {
    return [
      'command' => 'courierTemplate',
      'template_collection' => $this->template_collection,
      'channel' => $this->channel,
      'operation' => $this->operation,
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CourierTemplate::$channel protected property Channel entity type ID.
CourierTemplate::$operation protected property Operation to execute on client.
CourierTemplate::$template_collection protected property A template collection entity ID.
CourierTemplate::render public function Implements \Drupal\Core\Ajax\CommandInterface::render(). Overrides CommandInterface::render
CourierTemplate::__construct public function Constructs a \Drupal\courier\Ajax\CourierTemplate object.