You are here

public function EditorNoteHelperService::getWidgetAjaxReplaceCommand in Editor Notes 8

Returns ajax replace command for refreshing field widget.

Parameters

\Drupal\editor_note\Entity\EditorNote $editorNote:

Return value

\Drupal\Core\Ajax\ReplaceCommand

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

File

src/EditorNoteHelperService.php, line 199

Class

EditorNoteHelperService
Class EditorNoteHelperService.

Namespace

Drupal\editor_note

Code

public function getWidgetAjaxReplaceCommand(EditorNote $editorNote) {
  $field_config = $this
    ->getNoteFieldDefinition($editorNote);
  $host_entity_id = $editorNote->entity_id->target_id;
  $field_machine_name = $editorNote->field_machine_name->value;
  $widget_settings = $this
    ->getNoteFieldWidgetSettings($editorNote, $field_machine_name);
  $notes = $this
    ->getNotesByEntityAndField($host_entity_id, $field_machine_name, $widget_settings);
  $table = $this
    ->generateTable($field_config, $notes, TRUE);
  return new ReplaceCommand('#formatted_notes_' . $field_machine_name, $table);
}