You are here

class AddParagraphTypeCommand in Paragraphs Browser 8

AJAX command to trigger related paragraph add on host form.

Hierarchy

Expanded class hierarchy of AddParagraphTypeCommand

1 file declares its use of AddParagraphTypeCommand
ParagraphsBrowserForm.php in src/Form/ParagraphsBrowserForm.php
Contains \Drupal\paragraphs_browser\Form\ParagraphsBrowserForm.

File

src/Ajax/AddParagraphTypeCommand.php, line 10

Namespace

Drupal\paragraphs_browser\Ajax
View source
class AddParagraphTypeCommand implements CommandInterface {

  /**
   * A unique identifier.
   *
   * @var string
   */
  protected $uuid;

  /**
   * A paragraphs bundle name.
   *
   * @var array
   */
  protected $paragraph_type;

  /**
   * Constructs a \Drupal\entity_browser\Ajax\AddParagraphTypeCommand object.
   *
   * @param string $uuid
   *   Entity browser instance UUID.
   * @param array $paragraph_type
   *   The type of paragraph that was selected.
   */
  public function __construct($uuid, $paragraph_type) {
    $this->uuid = $uuid;
    $this->paragraph_type = $paragraph_type;
  }

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

}

Members

Namesort descending Modifiers Type Description Overrides
AddParagraphTypeCommand::$paragraph_type protected property A paragraphs bundle name.
AddParagraphTypeCommand::$uuid protected property A unique identifier.
AddParagraphTypeCommand::render public function Implements \Drupal\Core\Ajax\CommandInterface::render(). Overrides CommandInterface::render
AddParagraphTypeCommand::__construct public function Constructs a \Drupal\entity_browser\Ajax\AddParagraphTypeCommand object.