protected convertObjectTo ( eZ\Publish\API\Repository\Values\ValueObject $object, string $type ) : |
||
$object | eZ\Publish\API\Repository\Values\ValueObject | Object to be converted |
$type | string | Type for conversion |
return |
protected function convertObjectTo(ValueObject $object, $type)
{
$type = strtolower($type);
switch ($type) {
case 'json':
case 'xml':
$visitor = $this->getKernel()->getContainer()->get('ezpublish_rest.output.visitor.' . $type);
break;
default:
throw new InvalidArgumentException('rest body type', $type);
}
return $visitor->visit($object);
}