Merge pull request #2602 from mike-esokia/PHRAS-2053_PORT_PHRAS_2051_to_4.1

PHRAS-2053 port PHRAS 2051 to 4.1
This commit is contained in:
Nicolas Maillat
2018-05-23 11:11:55 +02:00
committed by GitHub
2 changed files with 18 additions and 2 deletions

View File

@@ -127,6 +127,22 @@ class TwigServiceProvider implements ServiceProviderInterface
);
}, ['needs_environment' => true, 'is_safe' => ['html']]));
$twig->addFilter(new \Twig_SimpleFilter('parseColor', function (\Twig_Environment $twig, $string) use ($app) {
$re = '/^(.*)\[#([0-9a-fA-F]{6})]$/m';
$stringArr = explode(';', $string);
foreach ($stringArr as $key => $value) {
preg_match_all($re, trim($value), $matches);
if ($matches && $matches[1] != null && $matches[2] != null) {
$colorCode = '#' . $matches[2][0];
$colorName = $matches[1][0];
$stringArr[$key] = '<span class="color-dot" style="margin-right: 4px; background-color: ' . $colorCode . '"></span>' . $colorName . '<br />';
}
}
return implode('', $stringArr);
}, ['needs_environment' => true, 'is_safe' => ['html']]));
$twig->addFilter(new \Twig_SimpleFilter('bounce',
function (\Twig_Environment $twig, $fieldValue, $fieldName, $searchRequest, $sbasId) {
// bounce value if it is present in thesaurus as well