setFormatters() public static method

Set the response formatters.
public static setFormatters ( array $formatters ) : void
$formatters array
return void
Example #1
0
 public function setUp()
 {
     $this->events = new Dispatcher();
     $this->config = new Properties('v1', null, null, 'testing', 'json', false);
     $this->router = new Router($this->events, $this->config);
     Response::setFormatters(['json' => new JsonResponseFormat()]);
 }
Example #2
0
 /**
  * Boot the service provider.
  *
  * @return void
  */
 public function boot()
 {
     $this->setupConfig();
     Http\Response::setFormatters($this->prepareConfigValues($this->app['config']['api.formats']));
     Http\Response::setTransformer($this->app['api.transformer']);
     Http\Response::setEventDispatcher($this->app['events']);
     $this->app->rebinding('api.routes', function ($app, $routes) {
         $app['api.url']->setRouteCollections($routes);
     });
 }
 public function setUp()
 {
     $this->auth = m::mock('Dingo\\Api\\Auth\\Shield');
     $this->router = new Router(new EventsDispatcher());
     $this->router->setDefaultVersion('v1');
     $this->router->setVendor('testing');
     $this->dispatcher = new Dispatcher(new Request(), new UrlGenerator(new RouteCollection(), new Request()), $this->router, $this->auth);
     Response::setFormatters(['json' => new JsonResponseFormat()]);
     Response::setTransformer(m::mock('Dingo\\Api\\Transformer\\Transformer')->shouldReceive('transformableResponse')->andReturn(false)->getMock()->shouldReceive('setRequest')->getMock());
 }
Example #4
0
 public function setUp()
 {
     $config = new Properties('v1', null, null, 'test');
     $this->container = new Container();
     $this->container['request'] = Request::create('/', 'GET');
     $url = new UrlGenerator(new RouteCollection(), $this->container['request']);
     $this->router = new Router(new EventDispatcher(), $config);
     $this->auth = new Authenticator($this->router, $this->container, []);
     $this->dispatcher = new Dispatcher($this->container, new Filesystem(), $url, $this->router, $this->auth, $config);
     Response::setFormatters(['json' => new JsonResponseFormat()]);
 }
 public function setUp()
 {
     $this->container = new Container();
     $this->container['Illuminate\\Container\\Container'] = $this->container;
     $this->container['api.auth'] = new MiddlewareStub();
     $this->container['api.limiting'] = new MiddlewareStub();
     $this->container['request'] = new Http\Request();
     $this->adapter = $this->getAdapterInstance();
     $this->exception = m::mock('Dingo\\Api\\Exception\\Handler');
     $this->router = new Router($this->adapter, new Http\Parser\Accept('vnd', 'api', 'v1', 'json'), $this->exception, $this->container, null, null);
     Http\Response::setFormatters(['json' => new Http\Response\Format\Json()]);
 }
 /**
  * Boot the service provider.
  *
  * @return void
  */
 public function boot()
 {
     $this->setupConfig();
     Http\Response::setFormatters($this->prepareConfigValues($this->app['config']['api.formats']));
     Http\Response::setTransformer($this->app['api.transformer']);
     Http\Response::setEventDispatcher($this->app['events']);
     $config = $this->app['config']['api'];
     Http\Request::setAcceptParser(new Http\Parser\Accept($config['standardsTree'], $config['subtype'], $config['version'], $config['defaultFormat']));
     $this->app->rebinding('api.routes', function ($app, $routes) {
         $app['api.url']->setRouteCollections($routes);
     });
 }
Example #7
0
 /**
  * Boot the service provider.
  *
  * @return void
  */
 public function boot()
 {
     $this->setupConfig();
     $this->app->singleton('Illuminate\\Contracts\\Debug\\ExceptionHandler', function ($app) {
         return $app['api.exception'];
     });
     Http\Response::setFormatters($this->prepareConfigValues($this->app['config']['api.formats']));
     Http\Response::setTransformer($this->app['api.transformer']);
     $this->app->rebinding('api.routes', function ($app, $routes) {
         $app['api.url']->setRouteCollections($routes);
     });
 }
 /**
  * Boot the response formats.
  *
  * @return array
  */
 protected function bootResponseFormats()
 {
     $formats = [];
     foreach ($this->app['config']['api::formats'] as $key => $format) {
         if (is_callable($format)) {
             $format = call_user_func($format, $this->app);
         }
         $formats[$key] = $format;
     }
     if (empty($formats)) {
         throw new RuntimeException('No registered response formats.');
     }
     ApiResponse::setFormatters($formats);
 }
 public function setUp()
 {
     $this->exceptionHandler = m::mock('Dingo\\Api\\ExceptionHandler');
     $this->router = new Router(new Dispatcher());
     $this->router->setExceptionHandler($this->exceptionHandler);
     $this->router->setDefaultVersion('v1');
     $this->router->setVendor('testing');
     $this->reviser = $this->router->getControllerReviser();
     Response::setFormatters(['json' => new JsonResponseFormat()]);
     $transformer = m::mock('Dingo\\Api\\Transformer\\Transformer');
     $transformer->shouldReceive('transformableResponse')->andReturn(false);
     $transformer->shouldReceive('setRequest');
     Response::setTransformer($transformer);
 }
 public function setUp()
 {
     $this->container = new Container();
     $this->container['request'] = Request::create('/', 'GET');
     $this->container['api.auth'] = new MiddlewareStub();
     $this->container['api.limiting'] = new MiddlewareStub();
     $this->transformerFactory = new TransformerFactory($this->container, new TransformerStub());
     $this->adapter = new RoutingAdapterStub();
     $this->exception = m::mock('Dingo\\Api\\Exception\\Handler');
     $this->router = new Router($this->adapter, new Http\Parser\Accept('vnd', 'api', 'v1', 'json'), $this->exception, $this->container, null, null);
     $this->auth = new Auth($this->router, $this->container, []);
     $this->dispatcher = new Dispatcher($this->container, new Filesystem(), $this->router, $this->auth);
     $this->dispatcher->setSubtype('api');
     $this->dispatcher->setStandardsTree('vnd');
     $this->dispatcher->setDefaultVersion('v1');
     $this->dispatcher->setDefaultFormat('json');
     Http\Response::setFormatters(['json' => new Http\Response\Format\Json()]);
     Http\Response::setTransformer($this->transformerFactory);
 }
Example #11
0
 protected function setResponseStaticInstances()
 {
     Response::setFormatters($this->config('formats'));
     Response::setTransformer($this->app['api.transformer']);
     Response::setEventDispatcher($this->app['events']);
 }
Example #12
0
 public function tearDown()
 {
     Mockery::close();
     Response::setFormatters([]);
 }
 public function tearDown()
 {
     Mockery::close();
     EloquentModelStub::$snakeAttributes = true;
     Response::setFormatters([]);
 }
Example #14
0
 /**
  * Boot the service provider.
  *
  * @return void
  */
 public function boot()
 {
     $this->setupContainerBindings();
     Response::setFormatters($this->prepareConfigInstances($this->app['config']['api::formats']));
     Response::setTransformer($this->app['api.transformer']);
 }