Skip to content

Commit de75ca9

Browse files
luckydonaldchriskacerguis
authored andcommitted
Move output format detection upwards (chriskacerguis#947)
to allow responses earlier, i.e. when handling exceptions, which might be thrown in Format::factory, in a REST_Controller subclass.
1 parent 34d8dab commit de75ca9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

application/libraries/REST_Controller.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,12 @@ public function __construct($config = 'rest')
507507
$this->{'_'.$this->request->method.'_args'} = [];
508508
}
509509

510+
// Which format should the data be returned in?
511+
$this->response->format = $this->_detect_output_format();
512+
513+
// Which language should the data be returned in?
514+
$this->response->lang = $this->_detect_lang();
515+
510516
// Now we know all about our request, let's try and parse the body if it exists
511517
if ($this->request->format && $this->request->body)
512518
{
@@ -531,12 +537,6 @@ public function __construct($config = 'rest')
531537
$this->{'_'.$this->request->method.'_args'}
532538
);
533539

534-
// Which format should the data be returned in?
535-
$this->response->format = $this->_detect_output_format();
536-
537-
// Which language should the data be returned in?
538-
$this->response->lang = $this->_detect_lang();
539-
540540
// Extend this function to apply additional checking early on in the process
541541
$this->early_checks();
542542

0 commit comments

Comments
 (0)