public function resolve(ContainerInterface $container)
{
$expression = $this->expression;
$result = preg_replace_callback('#\\{([^\\{\\}]+)\\}#', function (array $matches) use($container) {
try {
return $container->get($matches[1]);
} catch (NotFoundException $e) {
throw new DependencyException(sprintf("Error while parsing string expression for entry '%s': %s", $this->getName(), $e->getMessage()), 0, $e);
}
}, $expression);
if ($result === null) {
throw new \RuntimeException(sprintf('An unknown error occurred while parsing the string definition: \'%s\'', $expression));
}
return $result;
}