Skip to content
Snippets Groups Projects
Commit 1fc8c1fa authored by Kevin Kaland's avatar Kevin Kaland
Browse files

Stub out main PDF handling route.

parent 00b33174
No related branches found
No related tags found
No related merge requests found
......@@ -17,3 +17,10 @@ fillpdf.forms_admin:
_permission: 'administer pdfs'
options:
_admin_route: TRUE
fillpdf.populate_pdf:
path: '/fillpdf'
defaults:
_content: '\Drupal\fillpdf\Controller\HandlePdfController::populatePdf'
requirements:
_custom_access: '\Drupal\fillpdf\FillPdfAccessController::checkLink'
services:
plugin.manager.fillpdf_backend:
class: Drupal\fillpdf\FillPdfBackendManager
parent: default_plugin_manager
\ No newline at end of file
parent: default_plugin_manager
fillpdf.link_manipulator:
class: Drupal\fillpdf\Service\FillPdfLinkManipulator
<?php
/**
* @file
* Contains \Drupal\fillpdf\Controller\HandlePdfController.
*/
namespace Drupal\fillpdf\Controller;
use Drupal\Core\Controller\ControllerBase;
class HandlePdfController extends ControllerBase {
public function populatePdf() {
// TODO: Extract the PDF parameters, and act accordingly - this is pretty much just calling FillPdfBackendPluginInterface::populateWithFieldData and then reading the FillPdfForm options to determine whether to serve as a file download or fill in the field data.
}
}
<?php
/**
* @file
* Contains \Drupal\fillpdf\FillPdfAccessController.
*/
namespace Drupal\fillpdf;
use Drupal\Core\Access\AccessResult;
class FillPdfAccessController {
function checkLink() {
// TODO: Actually do access checking here
return AccessResult::allowedIf(TRUE);
}
}
<?php
/**
* @file
* Contains \Drupal\fillpdf\FillPdfLinkManipulatorInterface.
*/
namespace Drupal\fillpdf;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* Defines an interface to allow parsing and building FillPDF Links.
*
* A guideline for functionality is that calling generateLink on the result
* of parseLink should return a string that would parse the same way as the
* original one.
*/
interface FillPdfLinkManipulatorInterface {
/**
* @param Request $request The request containing the query string to parse.
* @return array
*/
public function parseLink(Request $request);
/**
* @param array $parameters
* The array of parameters to be converted into a
* URL and query string.
* @return string
*/
public function generateLink(array $parameters);
}
<?php
/**
* @file
* Contains \Drupal\fillpdf\Service\FillPdfLinkManipulator.
*/
namespace Drupal\fillpdf\Service;
use Drupal\fillpdf\FillPdfLinkManipulatorInterface;
use Drupal\fillpdf\Request;
class FillPdfLinkManipulator implements FillPdfLinkManipulatorInterface {
/**
* @param Request $request The request containing the query string to parse.
* @return array
*/
public function parseLink(Request $request) {
// TODO: Implement parseLink() method.
}
/**
* @param array $parameters
* The array of parameters to be converted into a
* URL and query string.
* @return string
*/
public function generateLink(array $parameters) {
// TODO: Implement generateLink() method.
}
}
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