/**
  * Registers services on the given app.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  */
 public function register(Application $app)
 {
     $app['rest_normalizer.version'] = '0.1.0';
     $app['rest_normalizer.builder'] = $app->protect(function ($object = null) use($app) {
         $version = $app['rest_normalizer.version'];
         $request = $app['request'];
         /** @var $request \Symfony\Component\HttpFoundation\Request */
         $builder = ResponseBuilder::create($version, HttpMethod::valueOf($request->getMethod()), $object);
         foreach ($request->request->all() as $key => $value) {
             $parameter = Parameter::create($key, $value);
             $builder->addParameter($parameter);
         }
         return $builder;
     });
 }
 /**
  * Registers services on the given app.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  */
 public function register(Application $app)
 {
     if ($app->offsetGet('api.version') === false) {
         throw new \Exception('Missing api version');
     }
     $app['rest_normalizer.builder'] = $app->protect(function ($object = null) use($app) {
         $request = $app['request'];
         // @var $request Request
         $builder = ResponseBuilder::create($app['api.version'], HttpMethod::valueOf($request->getMethod()), $object);
         foreach ($request->request->all() as $key => $value) {
             $parameter = Parameter::create($key, $value);
             $builder->addParameter($parameter);
         }
         return $builder;
     });
 }
 private function getBuilder()
 {
     return ResponseBuilder::create('1.2', HttpMethod::GET());
 }