function OptimizedPhpArrayDumper::escape

Same name in other branches
  1. 8.9.x core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php \Drupal\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumper::escape()
  2. 10 core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php \Drupal\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumper::escape()
  3. 11.x core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php \Drupal\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumper::escape()

Escapes parameters.

Parameters

array $parameters: The parameters to escape for '%' characters.

Return value

array The escaped parameters.

1 call to OptimizedPhpArrayDumper::escape()
OptimizedPhpArrayDumper::prepareParameters in core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php
Prepares parameters for the PHP array dumping.

File

core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php, line 178

Class

OptimizedPhpArrayDumper
OptimizedPhpArrayDumper dumps a service container as a serialized PHP array.

Namespace

Drupal\Component\DependencyInjection\Dumper

Code

protected function escape(array $parameters) {
    $args = [];
    foreach ($parameters as $key => $value) {
        if (is_array($value)) {
            $args[$key] = $this->escape($value);
        }
        elseif (is_string($value)) {
            $args[$key] = str_replace('%', '%%', $value);
        }
        else {
            $args[$key] = $value;
        }
    }
    return $args;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.