From 0b15764574f28d38e2119aabb0534f0503bc5556 Mon Sep 17 00:00:00 2001 From: Bernd Oliver Suenderhauf <bos@suenderhauf.de> Date: Sat, 20 Apr 2019 05:19:00 +0200 Subject: [PATCH] Followup to: Issue #3046765 by Pancho, wizonesolutions: Discourage public:// scheme for storing populated PDFs --- fillpdf.install | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fillpdf.install b/fillpdf.install index f32b4b3..1a4fa78 100644 --- a/fillpdf.install +++ b/fillpdf.install @@ -7,10 +7,12 @@ use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\StreamWrapper\StreamWrapperInterface; +use Drupal\Component\Render\FormattableMarkup; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\fillpdf\Entity\FillPdfForm; use Drupal\fillpdf\Service\FillPdfAdminFormHelper; use Drupal\Core\Link; +use Drupal\Core\Url; /** * Add scheme field to FillPdfForm. @@ -152,8 +154,8 @@ function fillpdf_update_8107() { } $config->save(); - return new TranslatableMarkup('All currently available file storage schemes were added to FillPDF configuration. Please review at %link.', [ - '%link' => Link::createFromRoute(new TranslatableMarkup('FillPDF settings'), 'fillpdf.forms_admin'), + return new FormattableMarkup('All currently available file storage schemes were added to FillPDF configuration. Please review at <a href=":url">FillPDF settings</a>.', [ + ':url' => Url::fromRoute('fillpdf.settings')->setOption('base_url', \Drupal::request()->getBasePath())->toString(), ]); } @@ -169,15 +171,16 @@ function fillpdf_update_8108() { // a 'destination_path', we need to unset 'scheme' to ensure nothing changes. $updated_ids = []; foreach ($fillpdf_forms as $id => $form) { - if (empty($form->get('destination_path'))) { + if (empty($form->getStoragePath())) { $status = $form->set('scheme', NULL)->save(); if ($status === SAVED_UPDATED) { - $updated_ids[] = $id; + $base_path = ['base_url' => \Drupal::request()->getBasePath()]; + $updated_ids[] = Link::createFromRoute($id, 'entity.fillpdf_form.edit_form', ['fillpdf_form' => $id], $base_path)->toString(); } } } - return new TranslatableMarkup('The following FillPDF forms were updated: %list.', [ - '%list' => implode(', ', $updated_ids), + return new FormattableMarkup('The following FillPDF forms were updated to the changed storage logic: %list.', [ + '%list' => new FormattableMarkup(implode(', ', $updated_ids), []), ]); } -- GitLab