class FillPdfAdminFormHelper in FillPDF 5.0.x
Same name and namespace in other branches
- 8.4 src/Service/FillPdfAdminFormHelper.php \Drupal\fillpdf\Service\FillPdfAdminFormHelper
Various helper methods used in FillPDF administrative forms.
Hierarchy
- class \Drupal\fillpdf\Service\FillPdfAdminFormHelper implements FillPdfAdminFormHelperInterface
Expanded class hierarchy of FillPdfAdminFormHelper
4 files declare their use of FillPdfAdminFormHelper
- fillpdf.install in ./
fillpdf.install - Install functions for FillPDF.
- FillPdfForm.php in src/
Entity/ FillPdfForm.php - FillPdfFormField.php in src/
Entity/ FillPdfFormField.php - FillPdfSettingsForm.php in src/
Form/ FillPdfSettingsForm.php
1 string reference to 'FillPdfAdminFormHelper'
1 service uses FillPdfAdminFormHelper
File
- src/
Service/ FillPdfAdminFormHelper.php, line 17
Namespace
Drupal\fillpdf\ServiceView source
class FillPdfAdminFormHelper implements FillPdfAdminFormHelperInterface {
/**
* The module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* The config factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* The stream wrapper manager.
*
* @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface
*/
protected $streamWrapperManager;
/**
* The database connection.
*
* @var \Drupal\Core\Database\Connection
*/
protected $connection;
/**
* Constructs a FillPdfAdminFormHelper object.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
* @param \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface $stream_wrapper_manager
* The stream wrapper manager.
* @param \Drupal\Core\Database\Connection $connection
* The database connection.
*/
public function __construct(ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory, StreamWrapperManagerInterface $stream_wrapper_manager, Connection $connection) {
$this->moduleHandler = $module_handler;
$this->configFactory = $config_factory;
$this->streamWrapperManager = $stream_wrapper_manager;
$this->connection = $connection;
}
/**
* {@inheritdoc}
*/
public function getAdminTokenForm($token_types = 'all') {
return [
'#theme' => 'token_tree_link',
'#token_types' => $token_types,
'#global_types' => TRUE,
];
}
/**
* {@inheritdoc}
*/
public function schemeOptions(array $label_templates = []) {
$stream_wrapper_manager = $this->streamWrapperManager;
$options = [];
foreach (array_keys($stream_wrapper_manager
->getWrappers(StreamWrapperInterface::WRITE_VISIBLE)) as $scheme) {
$label_template = array_key_exists($scheme, $label_templates) ? $label_templates[$scheme] : '@scheme';
$options[$scheme] = new FormattableMarkup($label_template, [
'@scheme' => new FormattableMarkup("<strong>@label</strong>", [
'@label' => $stream_wrapper_manager
->getViaScheme($scheme)
->getName(),
]),
]) . ': ' . $stream_wrapper_manager
->getViaScheme($scheme)
->getDescription();
}
return $options;
}
/**
* {@inheritdoc}
*/
public function getFormsByTemplateScheme($scheme) {
$query = $this->connection
->query("SELECT u.id AS form_id, f.uri AS file_uri\n FROM {file_usage} u INNER JOIN {file_managed} f ON u.fid = f.fid\n WHERE (type = :type) AND (uri LIKE :scheme)", [
':type' => 'fillpdf_form',
':scheme' => "{$scheme}://%",
]);
return $query
->fetchAllKeyed();
}
/**
* {@inheritdoc}
*/
public static function getReplacementsDescription() {
return new TranslatableMarkup("<p>Tokens, such as those from fields, sometimes output values that need additional\n processing prior to being sent to the PDF. A common example is when a key within a field's <em>Allowed values</em>\n configuration does not match the field name or option value in the PDF that you would like to be selected but you\n do not want to change the <em>Allowed values</em> key.</p><p>This field will replace any matching values with the\n replacements you specify. Specify <strong>one replacement per line</strong> in the format\n <em>original value|replacement value</em>. For example, <em>yes|Y</em> will fill the PDF with\n <strong><em>Y</em></strong> anywhere that <strong><em>yes</em></strong> would have originally\n been used. <p>Note that omitting the <em>replacement value</em> will replace <em>original value</em>\n with a blank, essentially erasing it.</p>");
}
/**
* Returns the configured path to the local pdftk installation.
*
* @return string
* The configured path to the local pdftk installation.
*
* @deprecated in fillpdf:8.x-4.9 and is removed from fillpdf:8.x-5.0. Use the
* PdfBackend plugin's own methods.
*
* @see https://www.drupal.org/node/3060086
* @see \Drupal\fillpdf\Plugin\PdfBackend\PdftkPdfBackend
*/
public function getPdftkPath() {
$path_to_pdftk = $this->configFactory
->get('fillpdf.settings')
->get('pdftk_path');
if (empty($path_to_pdftk)) {
$path_to_pdftk = 'pdftk';
return $path_to_pdftk;
}
return $path_to_pdftk;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FillPdfAdminFormHelper:: |
protected | property | The config factory. | |
FillPdfAdminFormHelper:: |
protected | property | The database connection. | |
FillPdfAdminFormHelper:: |
protected | property | The module handler. | |
FillPdfAdminFormHelper:: |
protected | property | The stream wrapper manager. | |
FillPdfAdminFormHelper:: |
public | function |
Returns render array for a link to a token tree shown as a dialog. Overrides FillPdfAdminFormHelperInterface:: |
|
FillPdfAdminFormHelper:: |
public | function |
Returns all FillPdfForms with template PDFs stored in a particular scheme. Overrides FillPdfAdminFormHelperInterface:: |
|
FillPdfAdminFormHelper:: |
public | function | Returns the configured path to the local pdftk installation. | |
FillPdfAdminFormHelper:: |
public static | function |
Returns the help text for FillPDF replacements. Overrides FillPdfAdminFormHelperInterface:: |
|
FillPdfAdminFormHelper:: |
public | function |
Returns available file storage options for use with FAPI radio buttons. Overrides FillPdfAdminFormHelperInterface:: |
|
FillPdfAdminFormHelper:: |
public | function | Constructs a FillPdfAdminFormHelper object. |