eZ\Bundle\EzPublishRestBundle\Features\Context\SubContext\EzRest::convertObjectTo PHP Method

convertObjectTo() protected method

Convert an object to a request.
protected convertObjectTo ( eZ\Publish\API\Repository\Values\ValueObject $object, string $type ) : Response
$object eZ\Publish\API\Repository\Values\ValueObject Object to be converted
$type string Type for conversion
return Symfony\Component\HttpFoundation\Response
    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);
    }