How do I programmatically get the link for a webform submission? I have managed to create a table of webform submissions of a particular type, thanks to the answer from a question posted here.  What I would like to do now is add a link for each webform submission, and I can't figure out how.

I tried looking through the API, and found a toUrl function, but I don't understand how to use it to get the link for each webform submission.  Once I have the link, I would like to combine it with the rest of its info in submission_data[] for display in the table.

Thanks in advance!

$query = \Drupal::entityQuery('webform_submission')
  -&gt;condition('webform_id', 'sign_up');
$result = $query-&gt;execute(); // Gives me IDs associated with the "sign_up" webform.

$storage = \Drupal::entityTypeManager()-&gt;getStorage('webform_submission');
$submissions = $storage-&gt;loadMultiple($result);
$submission_data = array();
foreach ($submissions as $submission) {
  $submission_data[] = $submission-&gt;getData();
}
// $submission_data now contains all the submissions from "sign_up" webform.


How do I add a link to the webform submission? When I look through submission_data[] it doesn't contain the ID of the webform submission
Webform submissions are content entities, you can use any method defined in \Drupal\Core\Entity\EntityInterface including… 


$submission->toUrl();
$submission->toLink();