Gets variables filled notification content

@param string $content
@param array $variables
@return String
492899
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));
    }
381359
private function filterVariablesUsedAsPlaceholders($string, array $variables)
    {
        if (empty($string)) {
            return $variables;
        }

        // array_filter() is not used because ARRAY_FILTER_USE_KEY requires PHP 5.6
        $filteredVariables = array();
        foreach ($variables as $key => $value) {
            if (false === strpos($string, '{'.$key.'}')) {
                $filteredVariables[$key] = $value;
            }
        }

        return $filteredVariables;
    }
1209460
protected function prepare_merge_vars( array $notifications ) {

		$merge_vars = array();

		foreach ( $notifications as $notification ) {
			$merge = array(
				'rcpt' => $notification->get_recipient()->user_email,
				'vars' => array()
			);

			foreach ( $notification->get_tags() as $tag => $val ) {

				$tag = str_replace( array( '{', '}' ), '', $tag );

				$merge['vars'][] = array(
					'name'    => $tag,
					'content' => $val
				);
			}

			$merge_vars[] = $merge;
		}

		return $merge_vars;
	}
438962
public static function script(
        string $content, 
        array $attributes = ["type" => "text/javascript"],
        bool $addCdataTag = true
    ) : string
    {
        if ($addCdataTag) {
            $content = "\n//<![CDATA[\n" . $content ."\n//]]>\n";
        }
        return self::tag("script", $content, $attributes);
    }
1143899
public function render(string $view = '', array $variables = []): string
    {
        if (!empty($view)) {
            $this->setView($view);
        }
        $this->assign($variables);
        $content = $this->renderView();
        if (empty($this->layout)) {
            return $content;
        }
        return $this->renderLayout($content);
    }
576872
protected function display($content, $vars = [], $config = [])
    {
        $this->beforeViewRender();

        return $this->view->fetch($content, $vars, $config, true);
    }
1091668
public static function getArrayKeys($content)
    {
        preg_match_all(self::ARRAY_KEYS_REGEX, trim($content), $matches);

        return !empty($matches) ? $matches[1] : array();
    }
1289760
protected static function replaceEnvironmentVariables($content) : string
    {
        preg_match_all("/\:\:getenv\(\'(.*)\'\)/", $content, $result);

        $findEnvs = [];

        foreach ($result[1] as $envVar)
        {
            if(!in_array($envVar, $findEnvs))
            {
                $toReplace = "::getenv('{$envVar}')";
                $replaceWith = getenv($envVar);
                $content = str_replace($toReplace, $replaceWith, $content);
                unset($replaceWith);
            }
        }

        return $content;
    }
1320501
public function replace($contents, array $variables = [], array $replacements = [])
    {
        $contents = str_replace($variables, $replacements, $contents);
        $contents = preg_replace('/^ +$/m', '', $contents);

        return $contents;
    }
266656
public function header(array $var = null)
    {
        $content = $this->content();

        if ($var !== null) {
            $content['header'] = $var;
            $this->content($content);
        }

        return $content['header'];
    }
408557
public function buildString(array $variables = [], bool $useExisting = true): string
    {
        if ($useExisting === true) {
            $variables = \array_merge($this->variables, $variables);
        }

        $tmp = [];
        foreach ($variables as $name => $val) {
            if ($val !== null) {
                $tmp[] = $name.'='.\urlencode((string)$val);
            }
        }

        $ret = '';
        if (\count($tmp) > 0) {
            $ret .= '?'.\implode('&', $tmp);
        }
        return $ret;
    }
875426
public function replaceContents($contents)
    {
        preg_match_all('/{{(.*)}}/', $contents, $matches);

        foreach ($matches[0] as $key => $match) {
            if (!empty($match)) {
                if (($resolved = $this->resolveVariable($matches[1][$key])) !== Constants::NOT_RESOLVED) {
                    $contents = str_replace($matches[0][$key], $resolved, $contents);
                }
            }
        }

        return $contents;
    }
1070833
protected function _getContent($content)
    {
        if(!isset($content))
            return;

        if(is_array($content))
            return array_map(
                function ($value) {
                    return $this->_getContent($value);
                }, $content
            );

        switch(gettype($content)) {
            case 'string': case 'integer': case 'double': case 'float':
                return $content;
            break;
            case 'object':
                if('Closure' == get_class($content)) {
                    ob_start();
                    ob_clean();
                    $returned = $content($this->data);
                    $output = ob_get_clean();
                    if(isset($returned))
                        return $returned;
                    else
                        return $output;
                } elseif(isset($content->content))
                    return $content->content;
            break;
            default:
                throw new \InvalidArgumentException('wrong view content type : '.gettype($content));
        }
    }
519006
private function getContentData($content)
    {
        $res = [];
        $res['startStringPos'] = strpos($content, $this->startString) + strlen($this->startString);
        $res['endStringPos'] = strpos($content, $this->endString);
        $res['bundleList'] = substr($content, $res['startStringPos'], ($res['endStringPos'] - $res['startStringPos']));
        return $res;
    }
564785
public function getSerializedContent($content)
    {
        $serializationContext = clone $this->serializationContext;

        return $this->serializer->serialize(
            $content,
            'json',
            $serializationContext
        );
    }
790170
private function getFullContent(string $content, array $params = [])
    {
        return str_replace(array_map(function ($key) {
            return '${' . $key . '}';
        }, array_keys($params)), array_values($params), $content);
    }
420100
public function show($content, $vars = [])
    {
        // 关闭模板布局
        $this->view->engine->layout(false);

        echo $this->view->fetch($content, $vars, [], [], true);
    }