public function before($controller, $metadata, &$data, &$args) { $body = @file_get_contents('php://input'); if (!$body) { throw new BadRequestException(); } $site = null; $ctype = array_shift(explode(';', $_SERVER['CONTENT_TYPE'])); switch ($ctype) { case 'application/xml': case 'text/xml': $site = Serializer::DeserializeObject($body, Serializer::FORMAT_XML, $metadata->map); break; case 'application/json': case 'text/json': $site = Serializer::DeserializeObject($body, Serializer::FORMAT_JSON, $metadata->map); break; case 'text/yaml': $site = Serializer::DeserializeObject($body, Serializer::FORMAT_YAML, $metadata->map); break; } $args[] = $site; }