concrete/src/Editor/LinkAbstractor.php
protected static function replacePlaceholder($text, $pattern, callable $resolver, $caseSensitive = false)
    {
        $regex = "/{$pattern}/";
        if (!$caseSensitive) {
            $regex .= 'i';
        }
        if (!preg_match_all($regex, $text, $matches)) {
            return $text;
        }
        $replaces = array_combine($matches[0], $matches[1]);
        if (!$caseSensitive) {
            $replaces = array_change_key_case($replaces, CASE_UPPER);
        }
        foreach (array_keys($replaces) as $key) {
            $replaces[$key] = (string) $resolver($replaces[$key]);
        }

        return $caseSensitive ? strtr($text, $replaces) : str_ireplace(array_keys($replaces), array_values($replaces), $text);
    }
protected static function replacePlaceholder($text, $pattern, callable $resolver, $caseSensitive = false)
    {
        $regex = "/{$pattern}/";
        if (!$caseSensitive) {
            $regex .= 'i';
        }
        if (!preg_match_all($regex, $text, $matches)) {
            return $text;
        }
        $replaces = array_combine($matches[0], $matches[1]);
        if (!$caseSensitive) {
            $replaces = array_change_key_case($replaces, CASE_UPPER);
        }
        foreach (array_keys($replaces) as $key) {
            $replaces[$key] = (string) $resolver($replaces[$key]);
        }

        return $caseSensitive ? strtr($text, $replaces) : str_ireplace(array_keys($replaces), array_values($replaces), $text);
    }
protected static function replacePlaceholder ( $ text , $ pattern , callable $ resolver , $ caseSensitive = false ) { $ regex = "/{$pattern}/" ; if ( ! $ caseSensitive ) { $ regex .= 'i' ; } if ( ! preg_match_all ( $ regex , $ text , $ matches ) ) { return $ text ; } $ replaces = array_combine ( $ matches [ 0 ] , $ matches [ 1 ] ) ; if ( ! $ caseSensitive ) { $ replaces = array_change_key_case ( $ replaces , CASE_UPPER ) ; } foreach ( array_keys ( $ replaces ) as $ key ) { $ replaces [ $ key ] = ( string ) $ resolver ( $ replaces [ $ key ] ) ; } return $ caseSensitive ? strtr ( $ text , $ replaces ) : str_ireplace ( array_keys ( $ replaces ) , array_values ( $ replaces ) , $ text ) ; }
Replace a placeholder.

@param string $text the text that may contain placeholders to be replaced
@param string $pattern the regular expression (without enclosing '/') that captures the placeholder
@param callable $resolver a callback that replaces the captured placeholder value
@param bool $caseSensitive is $pattern case sensitive?

@return string

@since concrete5 8.5.0a3
Replace a placeholder .