You are here

public function WebformSignature::postDelete in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/WebformSignature.php \Drupal\webform\Plugin\WebformElement\WebformSignature::postDelete()

Delete any additional value associated with an element.

Currently only applicable to file uploads.

Parameters

array $element: An element.

\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.

Overrides WebformElementBase::postDelete

File

src/Plugin/WebformElement/WebformSignature.php, line 221

Class

WebformSignature
Provides a 'signature' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function postDelete(array &$element, WebformSubmissionInterface $webform_submission) {
  $webform = $webform_submission
    ->getWebform();
  $element_key = $element['#webform_key'];
  $sid = $webform_submission
    ->id();

  // Delete signature image submission directory.
  $image_base_directory = 'public://webform/' . $webform
    ->id();
  $image_directory = "{$image_base_directory}/{$element_key}/{$sid}";
  if (file_exists($image_directory)) {
    $this->fileSystem
      ->deleteRecursive($image_directory);
    $this->fileSystem
      ->deleteRecursive($image_directory);
  }

  // Please node, the signature image (no results) directory is deleted when
  // the Webform is deleted.
  // @see \Drupal\webform\WebformEntityStorage::delete
}