Skip to content
Snippets Groups Projects
Commit 0b157645 authored by Bernd Oliver Suenderhauf's avatar Bernd Oliver Suenderhauf
Browse files

Followup to: Issue #3046765 by Pancho, wizonesolutions: Discourage public://...

Followup to: Issue #3046765 by Pancho, wizonesolutions: Discourage public:// scheme for storing populated PDFs
parent ac3f0ba1
No related branches found
No related tags found
No related merge requests found
...@@ -7,10 +7,12 @@ ...@@ -7,10 +7,12 @@
use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\StreamWrapper\StreamWrapperInterface; use Drupal\Core\StreamWrapper\StreamWrapperInterface;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\fillpdf\Entity\FillPdfForm; use Drupal\fillpdf\Entity\FillPdfForm;
use Drupal\fillpdf\Service\FillPdfAdminFormHelper; use Drupal\fillpdf\Service\FillPdfAdminFormHelper;
use Drupal\Core\Link; use Drupal\Core\Link;
use Drupal\Core\Url;
/** /**
* Add scheme field to FillPdfForm. * Add scheme field to FillPdfForm.
...@@ -152,8 +154,8 @@ function fillpdf_update_8107() { ...@@ -152,8 +154,8 @@ function fillpdf_update_8107() {
} }
$config->save(); $config->save();
return new TranslatableMarkup('All currently available file storage schemes were added to FillPDF configuration. Please review at %link.', [ return new FormattableMarkup('All currently available file storage schemes were added to FillPDF configuration. Please review at <a href=":url">FillPDF settings</a>.', [
'%link' => Link::createFromRoute(new TranslatableMarkup('FillPDF settings'), 'fillpdf.forms_admin'), ':url' => Url::fromRoute('fillpdf.settings')->setOption('base_url', \Drupal::request()->getBasePath())->toString(),
]); ]);
} }
...@@ -169,15 +171,16 @@ function fillpdf_update_8108() { ...@@ -169,15 +171,16 @@ function fillpdf_update_8108() {
// a 'destination_path', we need to unset 'scheme' to ensure nothing changes. // a 'destination_path', we need to unset 'scheme' to ensure nothing changes.
$updated_ids = []; $updated_ids = [];
foreach ($fillpdf_forms as $id => $form) { foreach ($fillpdf_forms as $id => $form) {
if (empty($form->get('destination_path'))) { if (empty($form->getStoragePath())) {
$status = $form->set('scheme', NULL)->save(); $status = $form->set('scheme', NULL)->save();
if ($status === SAVED_UPDATED) { 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.', [ return new FormattableMarkup('The following FillPDF forms were updated to the changed storage logic: %list.', [
'%list' => implode(', ', $updated_ids), '%list' => new FormattableMarkup(implode(', ', $updated_ids), []),
]); ]);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment