You are here

protected function OptimizedPhpArrayDumper::escape in Service Container 7.2

Same name and namespace in other branches
  1. 7 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 lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php
Prepares parameters for the PHP array dumping.

File

lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php, line 173
Contains \Drupal\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumper.

Class

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

Namespace

Drupal\Component\DependencyInjection\Dumper

Code

protected function escape(array $parameters) {
  $args = array();
  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;
}