You are here

private function YamlDumper::dumpValue in Service Container 7

Same name and namespace in other branches
  1. 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php \Symfony\Component\DependencyInjection\Dumper\YamlDumper::dumpValue()

Dumps the value to YAML format.

Parameters

mixed $value:

Return value

mixed

Throws

RuntimeException When trying to dump object or resource

1 call to YamlDumper::dumpValue()
YamlDumper::addService in modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
Adds a service.

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php, line 243

Class

YamlDumper
YamlDumper dumps a service container as a YAML string.

Namespace

Symfony\Component\DependencyInjection\Dumper

Code

private function dumpValue($value) {
  if (is_array($value)) {
    $code = array();
    foreach ($value as $k => $v) {
      $code[$k] = $this
        ->dumpValue($v);
    }
    return $code;
  }
  elseif ($value instanceof Reference) {
    return $this
      ->getServiceCall((string) $value, $value);
  }
  elseif ($value instanceof Parameter) {
    return $this
      ->getParameterCall((string) $value);
  }
  elseif ($value instanceof Expression) {
    return $this
      ->getExpressionCall((string) $value);
  }
  elseif (is_object($value) || is_resource($value)) {
    throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.');
  }
  return $value;
}