You are here

protected function OptimizedPhpArrayDumper::escape in Drupal 8

Same name and namespace in other branches
  1. 9 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;
}