I'm attempting to perform a query on webform submissions so I can display all submissions submitted by a specific user. However I'm not sure how to make this query. I made a guess that webform submissions were nodes themselves and performed a query like this
$query = \Drupal::entityQuery('node')
->condition('type', 'webform');
$nids = $query->execute();
die(print_r($nids));
But it produced no results. Is there a way I can perform a query on webform submissions so that I can select all submissions authored by a specific user?
UPDATE: Looking through the webform module, I did see some code querying submissions.
$query = $this->getQuery();
$query->condition('webform_id', $webform->id());
$query->condition('in_draft', FALSE);
$query->range(0, 1);
This is exactly the kind of query I want to perform but when I try to use getQuery() I get
Call to undefined function Drupal\my_module\my_helper_class\getQuery()
I understand how to start entity queries for nodes like this
\Drupal::entityQuery('node')
But is there a way to start an entity query without specifying the entity type? Or is there a way to find out what kind of entity type webform queries are?
getQuery()
is only a method of the class that$this
is referring to. Could you build a simple view to do this and just feed it a UID argument?