TabledragWarningCommand.php

Same filename in other branches
  1. 11.x core/lib/Drupal/Core/Ajax/TabledragWarningCommand.php

Namespace

Drupal\Core\Ajax

File

core/lib/Drupal/Core/Ajax/TabledragWarningCommand.php

View source
<?php

namespace Drupal\Core\Ajax;

use Drupal\Core\Asset\AttachedAssets;

/**
 * AJAX command for conveying changed tabledrag rows.
 *
 * This command is provided an id of a table row then does the following:
 * - Marks the row as changed.
 * - If a message generated by the tableDragChangedWarning is not present above
 *   the table the row belongs to, that message is added there.
 *
 * @see Drupal.AjaxCommands.prototype.tabledragChanged
 *
 * @ingroup ajax
 */
class TabledragWarningCommand implements CommandInterface, CommandWithAttachedAssetsInterface {
    
    /**
     * Constructs a TableDragWarningCommand object.
     *
     * @param string $id
     *   The id of the changed row.
     * @param string $tabledrag_instance
     *   The identifier of the tabledrag instance.
     */
    public function __construct(string $id, string $tabledrag_instance) {
    }
    
    /**
     * {@inheritdoc}
     */
    public function render() {
        return [
            'command' => 'tabledragChanged',
            'id' => $this->id,
            'tabledrag_instance' => $this->tabledrag_instance,
        ];
    }
    
    /**
     * {@inheritdoc}
     */
    public function getAttachedAssets() {
        $assets = new AttachedAssets();
        $assets->setLibraries([
            'core/drupal.tabledrag.ajax',
        ]);
        return $assets;
    }

}

Classes

Title Deprecated Summary
TabledragWarningCommand AJAX command for conveying changed tabledrag rows.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.