diff --git a/src/Service/FillPdfLinkManipulator.php b/src/Service/FillPdfLinkManipulator.php index 35a26316049bd1d097bc60ead66e9ca3a13f3121..3de7592c61cd5e61b0a2d748c07b1f62f0d138bb 100644 --- a/src/Service/FillPdfLinkManipulator.php +++ b/src/Service/FillPdfLinkManipulator.php @@ -77,7 +77,7 @@ class FillPdfLinkManipulator implements FillPdfLinkManipulatorInterface { // Set the fid, merging in evaluated boolean flags. $context = [ 'fid' => $query['fid'], - ] + static::parseBooleanFlags($query); + ] + self::parseBooleanFlags($query); // Early return if PDF is just to be populated with sample data. if ($context['sample'] === TRUE) { @@ -95,7 +95,7 @@ class FillPdfLinkManipulator implements FillPdfLinkManipulatorInterface { } // Merge in parsed entities. - $context += static::parseEntityIds($query); + $context += self::parseEntityIds($query); return $context; } @@ -182,9 +182,9 @@ class FillPdfLinkManipulator implements FillPdfLinkManipulatorInterface { 'fid' => $parameters['fid'], ]; - $query += static::prepareBooleanFlags($parameters); + $query += self::prepareBooleanFlags($parameters); - $query += static::prepareEntityIds($parameters); + $query += self::prepareEntityIds($parameters); $fillpdf_link = Url::fromRoute('fillpdf.populate_pdf', [], diff --git a/tests/src/Functional/LinkManipulatorTest.php b/tests/src/Functional/LinkManipulatorTest.php index b7ee8aff8274be7dcb80224dea58752b3103f755..e27b202fe3ca5140e0d689696f89a09365a44ddd 100644 --- a/tests/src/Functional/LinkManipulatorTest.php +++ b/tests/src/Functional/LinkManipulatorTest.php @@ -5,6 +5,7 @@ namespace Drupal\Tests\fillpdf\Functional; use Drupal\Core\Url; use Drupal\Tests\BrowserTestBase; use Drupal\Tests\fillpdf\Traits\TestFillPdfTrait; +use Drupal\fillpdf\Service\FillPdfLinkManipulator; /** * @coversDefaultClass \Drupal\fillpdf\Service\FillPdfLinkManipulator @@ -81,7 +82,7 @@ class LinkManipulatorTest extends BrowserTestBase { 'sample' => TRUE, ]; $url = Url::fromRoute('fillpdf.populate_pdf', [], ['query' => $query]); - $context = \Drupal::service('fillpdf.link_manipulator')->parseLink($url); + $context = FillPdfLinkManipulator::parseLink($url); // Test 'fid' and 'sample' parameters are correctly set. $this->assertEquals($form_id, $context['fid']); diff --git a/tests/src/Functional/PdfPopulationTest.php b/tests/src/Functional/PdfPopulationTest.php index 0e727e6debc751a03b13de14a335131a2025e441..d9453e6548160115f5b9a754b64789dc302984f0 100644 --- a/tests/src/Functional/PdfPopulationTest.php +++ b/tests/src/Functional/PdfPopulationTest.php @@ -2,13 +2,13 @@ namespace Drupal\Tests\fillpdf\Functional; -use Drupal\Core\Url; use Drupal\Tests\taxonomy\Functional\TaxonomyTestTrait; use Drupal\file\Entity\File; use Drupal\fillpdf\Component\Utility\FillPdf; use Drupal\fillpdf\Entity\FillPdfForm; use Drupal\fillpdf\FieldMapping\ImageFieldMapping; use Drupal\fillpdf\FieldMapping\TextFieldMapping; +use Drupal\fillpdf\Service\FillPdfLinkManipulator; use Drupal\fillpdf_test\Plugin\FillPdfBackend\TestFillPdfBackend; use Drupal\user\Entity\Role; @@ -87,13 +87,11 @@ class PdfPopulationTest extends FillPdfTestBase { ]); // Hit the generation route, check the results from the test backend plugin. - $fillpdf_route = Url::fromRoute('fillpdf.populate_pdf', [], [ - 'query' => [ - 'fid' => $fillpdf_form->id(), - 'entity_id' => "node:{$node->id()}", - ], + $url = FillPdfLinkManipulator::generateLink([ + 'fid' => $fillpdf_form->id(), + 'entity_ids' => ['node' => [$node->id()]], ]); - $this->drupalGet($fillpdf_route); + $this->drupalGet($url); // We don't actually care about downloading the fake PDF. We just want to // check what happened in the backend. @@ -144,13 +142,11 @@ class PdfPopulationTest extends FillPdfTestBase { $this->mapFillPdfFieldsToEntityFields($entity_type, $fillpdf_form->getFormFields()); // Hit the generation route, check results from the test backend plugin. - $fillpdf_route = Url::fromRoute('fillpdf.populate_pdf', [], [ - 'query' => [ - 'fid' => $fillpdf_form->id(), - 'entity_id' => "{$entity_type}:{$entity->id()}", - ], + $url = FillPdfLinkManipulator::generateLink([ + 'fid' => $fillpdf_form->id(), + 'entity_ids' => [$entity_type => [$entity->id()]], ]); - $this->drupalGet($fillpdf_route); + $this->drupalGet($url); // We don't actually care about downloading the fake PDF. We just want to // check what happened in the backend. @@ -344,13 +340,11 @@ class PdfPopulationTest extends FillPdfTestBase { ]); // Hit the generation route, check the results from the test backend plugin. - $fillpdf_route = Url::fromRoute('fillpdf.populate_pdf', [], [ - 'query' => [ - 'fid' => $fillpdf_form->id(), - 'entity_id' => "node:{$node->id()}", - ], + $url = FillPdfLinkManipulator::generateLink([ + 'fid' => $fillpdf_form->id(), + 'entity_ids' => ['node' => [$node->id()]], ]); - $this->drupalGet($fillpdf_route); + $this->drupalGet($url); $this->assertSession()->pageTextNotContains('Merging the FillPDF Form failed'); // Check if what we're seeing really is a PDF file.