/** * Determine what submission should be used as the draft submission. * * @param \Drupal\eform\Entity\EFormType $eform_type * * @return \Drupal\Core\Entity\EntityInterface|null */ protected function getDraftSubmission(EFormType $eform_type) { if ($eform_type->isDraftable()) { $query = $this->entityStorage()->getQuery(); $query->condition('uid', $this->currentUser()->id()); $query->condition('draft', EFORM_DRAFT); $query->condition('type', $eform_type->id()); // Should not be more than 1 draft. $query->sort('created', 'DESC'); $ids = $query->execute(); if ($ids) { $id = array_shift($ids); // @todo Add alter hook here to allow other modules to change. // see Entityform Anonymous sub-module in Drupal 7. return $this->entityStorage()->load($id); } } return NULL; }