src/Adapter/VariablesAdapter.php
public function get($content, array $variables = [])
    {

        $replacements = [];
        $instruction  = 'foreach';

        foreach ($variables as $key => $values) {
            $inner = $this->getInnerInstruction($content, $instruction);
            foreach ($inner as $config) {
                if (!str_contains($config['cleared'], $key)) {
                    continue;
                }
                $replacements[$key] = $inner;
            }
        }
        if (!empty($replacements)) {
            foreach ($replacements as $key => $value) {
                foreach ($value as $element) {
                    $inner   = $this->renderByTwig($element['cleared'], $variables);
                    $content = str_replace(["[[{$instruction}]]", "[[/{$instruction}]]", $element['to_replace']], ['', '', $inner], $content);
                }
            }
        }

        $content = str_replace(['<p>', '</p>', '<br />'], '', $content);
        $filled  = $this->fill($content);

        preg_match_all('/\[\[(.*?)\]\]/', $content, $matches);

        if (!isset($matches[0]) or ! isset($matches[1])) {
            return $filled;
        }
        foreach ($matches[0] as $index => $variable) {
            $filled = str_replace($variable, '{{ ' . $matches[1][$index] . ' }}', $filled);
        }
        return $this->renderByTwig($filled, array_merge($variables, $this->variables));
    }
public function get($content, array $variables = [])
    {

        $replacements = [];
        $instruction  = 'foreach';

        foreach ($variables as $key => $values) {
            $inner = $this->getInnerInstruction($content, $instruction);
            foreach ($inner as $config) {
                if (!str_contains($config['cleared'], $key)) {
                    continue;
                }
                $replacements[$key] = $inner;
            }
        }
        if (!empty($replacements)) {
            foreach ($replacements as $key => $value) {
                foreach ($value as $element) {
                    $inner   = $this->renderByTwig($element['cleared'], $variables);
                    $content = str_replace(["[[{$instruction}]]", "[[/{$instruction}]]", $element['to_replace']], ['', '', $inner], $content);
                }
            }
        }

        $content = str_replace(['<p>', '</p>', '<br />'], '', $content);
        $filled  = $this->fill($content);

        preg_match_all('/\[\[(.*?)\]\]/', $content, $matches);

        if (!isset($matches[0]) or ! isset($matches[1])) {
            return $filled;
        }
        foreach ($matches[0] as $index => $variable) {
            $filled = str_replace($variable, '{{ ' . $matches[1][$index] . ' }}', $filled);
        }
        return $this->renderByTwig($filled, array_merge($variables, $this->variables));
    }
public function get ( $ content , array $ variables = [ ] ) { $ replacements = [ ] ; $ instruction = 'foreach' ; foreach ( $ variables as $ key => $ values ) { $ inner = $ this -> getInnerInstruction ( $ content , $ instruction ) ; foreach ( $ inner as $ config ) { if ( ! str_contains ( $ config [ 'cleared' ] , $ key ) ) { continue ; } $ replacements [ $ key ] = $ inner ; } } if ( ! empty ( $ replacements ) ) { foreach ( $ replacements as $ key => $ value ) { foreach ( $ value as $ element ) { $ inner = $ this -> renderByTwig ( $ element [ 'cleared' ] , $ variables ) ; $ content = str_replace ( [ "[[{$instruction}]]" , "[[/{$instruction}]]" , $ element [ 'to_replace' ] ] , [ '' , '' , $ inner ] , $ content ) ; } } } $ content = str_replace ( [ '<p>' , '</p>' , '<br />' ] , '' , $ content ) ; $ filled = $ this -> fill ( $ content ) ; preg_match_all ( '/\[\[(.*?)\]\]/' , $ content , $ matches ) ; if ( ! isset ( $ matches [ 0 ] ) or ! isset ( $ matches [ 1 ] ) ) { return $ filled ; } foreach ( $ matches [ 0 ] as $ index => $ variable ) { $ filled = str_replace ( $ variable , '{{ ' . $ matches [ 1 ] [ $ index ] . ' }}' , $ filled ) ; } return $ this -> renderByTwig ( $ filled , array_merge ( $ variables , $ this -> variables ) ) ; }
Gets variables filled notification content

@param string $content
@param array $variables
@return String
Gets variables filled notification content