You are here

public function ContentElementController::close in Content Synchronization 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Controller/ContentElementController.php \Drupal\content_sync\Controller\ContentElementController::close()
  2. 8 src/Controller/ContentElementController.php \Drupal\content_sync\Controller\ContentElementController::close()

Returns response for message close using user or state storage.

Parameters

string $storage: Mechanism that the message state should be stored in, user or state.

string $id: The unique id of the message.

Return value

\Drupal\Core\Ajax\AjaxResponse An empty Ajax response.

Throws

\Exception Throws exception is storage is not set to 'user' or 'state'.

See also

\Drupal\content_sync\Element\ContentSyncMessage::setClosed

1 string reference to 'ContentElementController::close'
content_sync.routing.yml in ./content_sync.routing.yml
content_sync.routing.yml

File

src/Controller/ContentElementController.php, line 30

Class

ContentElementController
Provides route responses for content_sync element.

Namespace

Drupal\content_sync\Controller

Code

public function close($storage, $id) {
  if (!in_array($storage, [
    'user',
    'state',
  ])) {
    throw new \Exception('Undefined storage mechanism for Content Sync close message.');
  }
  ContentSyncMessage::setClosed($storage, $id);
  return new AjaxResponse();
}