1212use Drupal \Core \Extension \ModuleHandlerInterface ;
1313use Drupal \Core \Entity \EntityTypeManagerInterface ;
1414use Drupal \Core \Form \FormStateInterface ;
15- use Drupal \Core \Url ;
1615use Drupal \file \Entity \File ;
1716use Drupal \webform \Element \WebformMessage ;
1817use Drupal \webform \Plugin \WebformElement \BooleanBase ;
@@ -239,7 +238,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
239238
240239 $ path_pattern = ['public ' => 'public?:\/\/ ' ];
241240 if (\Drupal::service ('file_system ' )->realpath ("private:// " )) {
242- $ path_pattern ['private ' ] = 'private?:\/\/ ' ;
241+ $ path_pattern ['private ' ] = 'private?:\/\/ ' ;
243242 }
244243
245244 foreach ($ states as $ state => $ state_item ) {
@@ -394,6 +393,8 @@ public function postDelete(WebformSubmissionInterface $webform_submission) {
394393 * depending on the last save operation performed.
395394 * @param \Drupal\webform\WebformSubmissionInterface $webform_submission
396395 * The webform submission to be posted.
396+ *
397+ * @throws \Exception
397398 */
398399 protected function saveFile ($ state , WebformSubmissionInterface $ webform_submission ) {
399400 $ file_path = $ this ->getFilePath ($ state , $ webform_submission );
@@ -404,15 +405,15 @@ protected function saveFile($state, WebformSubmissionInterface $webform_submissi
404405 $ file_type = $ this ->configuration ['file_type ' ];
405406 try {
406407 $ data = $ this ->getRequestData ($ state , $ webform_submission );
407- /** @var FileSystemInterface $file_system */
408+ /** @var \Drupal\Core\File\ FileSystemInterface $file_system */
408409 $ file_system = \Drupal::service ('file_system ' );
409410 $ file_dir = $ file_system ->dirname ($ file_path );
410411 if (!file_exists ($ file_dir )) {
411412 $ file_system ->mkdir ($ file_dir , NULL , TRUE );
412413 }
413- $ file_system ->saveData ($ data , $ file_path , FileSystemInterface::EXISTS_REPLACE );
414+ $ file_system ->saveData ($ data , $ file_path , FileSystemInterface::EXISTS_REPLACE );
414415 }
415- catch ( FileWriteException $ e ) {
416+ catch (FileWriteException $ e ) {
416417 $ this ->handleError ($ state , $ e ->getMessage (), $ file_path , $ file_type );
417418 return ;
418419 }
@@ -421,7 +422,18 @@ protected function saveFile($state, WebformSubmissionInterface $webform_submissi
421422 $ this ->debug (t ('Save to file successful! ' ), $ state , $ file_path );
422423 }
423424
424- function getFilePath ($ state , WebformSubmissionInterface $ webform_submission ) {
425+ /**
426+ * Gets file path to save data.
427+ *
428+ * @param string $state
429+ * String state of webform submission.
430+ * @param \Drupal\webform\WebformSubmissionInterface $webform_submission
431+ * Webform submission entity object.
432+ *
433+ * @return string|null
434+ * File path string or null.
435+ */
436+ protected function getFilePath ($ state , WebformSubmissionInterface $ webform_submission ) {
425437 $ state_path = $ this ->configuration [$ state . '_path ' ];
426438 if (empty ($ state_path )) {
427439 return NULL ;
@@ -442,7 +454,8 @@ function getFilePath($state, WebformSubmissionInterface $webform_submission) {
442454 * depending on the last save operation performed.
443455 * @param \Drupal\webform\WebformSubmissionInterface $webform_submission
444456 * The webform submission to be posted.
445- * @throws
457+ *
458+ * @throws \Exception
446459 *
447460 * @return array
448461 * A webform submission converted to an associative array.
@@ -554,7 +567,8 @@ protected function castRequestValues(array $element, WebformElementInterface $el
554567 * The element's webform plugin.
555568 * @param mixed $value
556569 * The element's value.
557- * @throws
570+ *
571+ * @throws \Exception
558572 *
559573 * @return mixed
560574 * The element's value cast to boolean or float when appropriate.
@@ -641,10 +655,6 @@ protected function isConvertEnabled() {
641655 return $ this ->isDraftEnabled () && ($ this ->getWebform ()->getSetting ('form_convert_anonymous ' ) === TRUE );
642656 }
643657
644- /****************************************************************************/
645- // Debug and exception handlers.
646- /****************************************************************************/
647-
648658 /**
649659 * Display debugging information.
650660 *
@@ -720,7 +730,7 @@ protected function debug($message, $state, $file_path, $type = 'warning') {
720730 * @param string $file_type
721731 * The file type.
722732 *
723- * @throws
733+ * @throws \Drupal\Core\Entity\EntityMalformedException
724734 */
725735 protected function handleError ($ state , $ message , $ file_path , $ file_type ) {
726736 global $ base_url , $ base_path ;
0 commit comments