public function WebformSubmissionController::locked in Webform 8.5
Same name and namespace in other branches
- 6.x src/Controller/WebformSubmissionController.php \Drupal\webform\Controller\WebformSubmissionController::locked()
Toggle webform submission locked.
Parameters
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
Return value
\Drupal\Core\Ajax\AjaxResponse An Ajax response that toggle the lock icon.
1 string reference to 'WebformSubmissionController::locked'
File
- src/Controller/ WebformSubmissionController.php, line 109 
Class
- WebformSubmissionController
- Provides route responses for Webform submissions.
Namespace
Drupal\webform\ControllerCode
public function locked(WebformSubmissionInterface $webform_submission) {
  // Toggle locked.
  $webform_submission
    ->setLocked(!$webform_submission
    ->isLocked())
    ->save();
  // Get selector.
  $selector = '#webform-submission-' . $webform_submission
    ->id() . '-locked';
  $response = new AjaxResponse();
  // Update lock.
  $response
    ->addCommand(new HtmlCommand($selector, static::buildLocked($webform_submission)));
  // Announce lock status.
  $t_args = [
    '@label' => $webform_submission
      ->label(),
  ];
  $text = $webform_submission
    ->isLocked() ? $this
    ->t('@label locked.', $t_args) : $this
    ->t('@label unlocked.', $t_args);
  $response
    ->addCommand(new AnnounceCommand($text));
  return $response;
}