Set the transformer factory instance.
public static setTransformer ( Dingo\Api\Transformer\Factory $transformer ) : void | ||
$transformer | Dingo\Api\Transformer\Factory | |
Résultat | void |
public function setUp() { $this->formatter = m::mock('Dingo\\Api\\Http\\ResponseFormat\\JsonResponseFormat'); $this->formatter->shouldReceive('getContentType')->andReturn('foo'); Response::setFormatters(['json' => $this->formatter]); Response::setTransformer(m::mock('Dingo\\Api\\Transformer\\Transformer')->shouldReceive('transformableResponse')->andReturn(false)->getMock()); }
/** * 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()); }
/** * 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); }); }
/** * 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); }); }
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); }
protected function setResponseStaticInstances() { Response::setFormatters($this->config('formats')); Response::setTransformer($this->app['api.transformer']); Response::setEventDispatcher($this->app['events']); }
/** * Boot the response transformer. * * @return void */ protected function bootResponseTransformer() { ApiResponse::setTransformer($this->app['dingo.api.transformer']); }
public function setUp() { Response::setFormatters(['json' => new JsonResponseFormat()]); Response::setTransformer(m::mock('Dingo\\Api\\Transformer\\Transformer')->shouldReceive('transformableResponse')->andReturn(false)->getMock()); }
/** * 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']); }