public static function FillPdfMappingHelper::parseReplacements in FillPDF 8.4
Same name and namespace in other branches
- 5.0.x src/Component/Helper/FillPdfMappingHelper.php \Drupal\fillpdf\Component\Helper\FillPdfMappingHelper::parseReplacements()
Parses replacements.
Parameters
string $replacements_string: The replacements string.
Return value
string[] Associative array of replacement values, keyed by the value to be replaced.
1 call to FillPdfMappingHelper::parseReplacements()
- BackendProxy::merge in src/
Service/ BackendProxy.php
File
- src/
Component/ Helper/ FillPdfMappingHelper.php, line 22
Class
- FillPdfMappingHelper
- Class FillPdfMappingHelper.
Namespace
Drupal\fillpdf\Component\HelperCode
public static function parseReplacements($replacements_string) {
if (!empty($replacements_string)) {
$standardized_replacements = str_replace([
"\r\n",
"\r",
], "\n", $replacements_string);
$lines = explode("\n", $standardized_replacements);
$return = [];
foreach ($lines as $replacement) {
if (!empty($replacement)) {
$split = explode('|', $replacement);
// Sometimes it isn't; don't know why.
if (count($split) == 2) {
$return[$split[0]] = preg_replace('|<br />|', '
', $split[1]);
}
}
}
return $return;
}
else {
return [];
}
}