You are here

class LayoutParagraphsInsertCommand in Layout Paragraphs 1.0.x

Class LayoutParagraphsStateResetCommand.

Hierarchy

Expanded class hierarchy of LayoutParagraphsInsertCommand

1 file declares its use of LayoutParagraphsInsertCommand
LayoutParagraphsWidget.php in src/Plugin/Field/FieldWidget/LayoutParagraphsWidget.php

File

src/Ajax/LayoutParagraphsInsertCommand.php, line 12

Namespace

Drupal\layout_paragraphs\Ajax
View source
class LayoutParagraphsInsertCommand implements CommandInterface, CommandWithAttachedAssetsInterface {
  use CommandWithAttachedAssetsTrait;

  /**
   * The layout element settings array.
   *
   * @var array
   */
  protected $settings;

  /**
   * The content for the matched element(s).
   *
   * Either a render array or an HTML string.
   *
   * @var string|array
   */
  protected $content;

  /**
   * Constructs a LayoutParagraphsInsertCommand instance.
   */
  public function __construct($settings, $content) {
    $this->settings = $settings;
    $this->content = $content;
  }

  /**
   * Render custom ajax command.
   *
   * @return ajax
   *   Command function.
   */
  public function render() {
    return [
      'command' => 'layoutParagraphsInsert',
      'content' => $this
        ->getRenderedContent(),
      'settings' => $this->settings,
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CommandWithAttachedAssetsTrait::$attachedAssets protected property The attached assets for this Ajax command.
CommandWithAttachedAssetsTrait::getAttachedAssets public function Gets the attached assets.
CommandWithAttachedAssetsTrait::getRenderedContent protected function Processes the content for output.
LayoutParagraphsInsertCommand::$content protected property The content for the matched element(s).
LayoutParagraphsInsertCommand::$settings protected property The layout element settings array.
LayoutParagraphsInsertCommand::render public function Render custom ajax command. Overrides CommandInterface::render
LayoutParagraphsInsertCommand::__construct public function Constructs a LayoutParagraphsInsertCommand instance.