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