protected function _replaceReferences($input, ContainerInterface $container, $default = null, $startDelimiter = '${', $endDelimiter = '}')
    {
        $regexpDelimiter = '/';
        $input           = $this->_normalizeString($input);
        $defaultValue    = $default === null ? '' : $this->_normalizeString($default);

        $startDelimiter = preg_quote($this->_normalizeString($startDelimiter), $regexpDelimiter);
        $endDelimiter   = preg_quote($this->_normalizeString($endDelimiter), $regexpDelimiter);

        $regexp = $regexpDelimiter . $startDelimiter . '(.*?)' . $endDelimiter . $regexpDelimiter;

        preg_match_all($regexp, $input, $matches);

        foreach ($matches[0] as $i => $token) {
            $key = $matches[1][$i];
            try {
                $value = $container->get($key);
            } catch (NotFoundExceptionInterface $e) {
                $value = $defaultValue;
            }
            $input = str_replace($token, $value, $input);
        }

        return $input;
    }
protected function _replaceReferences($input, ContainerInterface $container, $default = null, $startDelimiter = '${', $endDelimiter = '}')
    {
        $regexpDelimiter = '/';
        $input           = $this->_normalizeString($input);
        $defaultValue    = $default === null ? '' : $this->_normalizeString($default);

        $startDelimiter = preg_quote($this->_normalizeString($startDelimiter), $regexpDelimiter);
        $endDelimiter   = preg_quote($this->_normalizeString($endDelimiter), $regexpDelimiter);

        $regexp = $regexpDelimiter . $startDelimiter . '(.*?)' . $endDelimiter . $regexpDelimiter;

        preg_match_all($regexp, $input, $matches);

        foreach ($matches[0] as $i => $token) {
            $key = $matches[1][$i];
            try {
                $value = $container->get($key);
            } catch (NotFoundExceptionInterface $e) {
                $value = $defaultValue;
            }
            $input = str_replace($token, $value, $input);
        }

        return $input;
    }
protected function _replaceReferences ( $ input , ContainerInterface $ container , $ default = null , $ startDelimiter = '${' , $ endDelimiter = '}' ) { $ regexpDelimiter = '/' ; $ input = $ this -> _normalizeString ( $ input ) ; $ defaultValue = $ default === null ? '' : $ this -> _normalizeString ( $ default ) ; $ startDelimiter = preg_quote ( $ this -> _normalizeString ( $ startDelimiter ) , $ regexpDelimiter ) ; $ endDelimiter = preg_quote ( $ this -> _normalizeString ( $ endDelimiter ) , $ regexpDelimiter ) ; $ regexp = $ regexpDelimiter . $ startDelimiter . '(.*?)' . $ endDelimiter . $ regexpDelimiter ; preg_match_all ( $ regexp , $ input , $ matches ) ; foreach ( $ matches [ 0 ] as $ i => $ token ) { $ key = $ matches [ 1 ] [ $ i ] ; try { $ value = $ container -> get ( $ key ) ; } catch ( NotFoundExceptionInterface $ e ) { $ value = $ defaultValue ; } $ input = str_replace ( $ token , $ value , $ input ) ; } return $ input ; }
Replaces all tokens wrapped with some delimiters in a string with corresponding values retrieved from a container.

@since [*next-version*]

@param string|Stringable  $input          Input string to find and replace references
@param ContainerInterface $container      Container to retrieve values for replace.
@param string|Stringable  $startDelimiter Starting delimiter of token for replace
@param mixed              $default        String to replace reference if key not found in container.
@param string|Stringable  $endDelimiter   Ending delimiter of token for replace

@throws ContainerExceptionInterface Error while retrieving the entry from the container.

@return string The resulting string.
Replaces all tokens wrapped with some delimiters in a string with corresponding values retrieved from a container .