Initial xentral_oss_20.3.c9ffacf

This commit is contained in:
Alex
2021-05-21 08:49:41 +02:00
parent 5406e4a551
commit 34e5ac43d9
18884 changed files with 2109867 additions and 0 deletions
@@ -0,0 +1,50 @@
<?php
namespace Xentral\Modules\Company\Service;
final class DocumentCustomizationBlockParser
{
/**
* @deprecated
*/
private $erp;
/**
* @param \erpAPI $erp
*/
public function __construct($erp)
{
$this->erp = $erp;
}
/**
* @param string $content
* @param array $variables
*
* @return string
*/
public function parse($content, $variables)
{
$elements = explode("\n", str_replace("\r", '', trim($content)));
foreach ($elements as $key => $el) {
if ($el === '') {
$elements[$key] = '|';
}
}
foreach ($elements as $key => $el) {
$el = trim($el);
$elements[$key] = $el;
foreach ($variables as $prevKey => $preVal) {
if (strpos($el, '{' . $prevKey . '}') !== false) {
$elements[$key] = trim(str_replace('{' . $prevKey . '}', $preVal, $el));
break;
}
}
}
$content = $this->erp->ParseIfVars(implode("\n", $elements));
return $this->erp->RemoveUnusedParsevars($content);
}
}