Skip to content

Commit 0ee4f24

Browse files
committed
Various cosmetic tweaks 💄
1 parent 9af2361 commit 0ee4f24

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
@@ -794,17 +794,17 @@ protected function _detect_input_format()
794794
*/
795795
protected function _detect_output_format()
796796
{
797+
// Concatenate formats to a regex pattern e.g. \.(csv|json|xml)
797798
$pattern = '/\.(' . implode('|', array_keys($this->_supported_formats)) . ')$/';
798799

799-
// Check if a file extension is used when no get arguments provided
800-
$matches = [];
801800
// Check if a file extension is used e.g. http://example.com/api/index.json?param1=param2
801+
$matches = [];
802802
if (preg_match($pattern, $this->uri->uri_string(), $matches))
803803
{
804804
return $matches[1];
805805
}
806806

807-
// Get the format
807+
// Get the format via the GET parameter labelled 'format'
808808
$format = isset($this->_get_args['format']) ? strtolower($this->_get_args['format']) : NULL;
809809

810810
// A format has been passed as an argument in the URL and it is supported
@@ -816,7 +816,7 @@ protected function _detect_output_format()
816816
// Get the HTTP_ACCEPT server variable
817817
$http_accept = $this->input->server('HTTP_ACCEPT');
818818

819-
// Otherwise, check the HTTP_ACCEPT (if it exists and we are allowed)
819+
// Otherwise, check the HTTP_ACCEPT server variable
820820
if ($this->config->item('rest_ignore_http_accept') === FALSE && $http_accept !== NULL)
821821
{
822822
// Check all formats against the HTTP_ACCEPT header
@@ -845,13 +845,13 @@ protected function _detect_output_format()
845845
}
846846
}
847847

848-
// Well, none of that has worked! Let's see if the controller has a default
848+
// Check if the controller has a default format
849849
if (empty($this->rest_format) === FALSE)
850850
{
851851
return $this->rest_format;
852852
}
853853

854-
// Just use the default format
854+
// Obtain the default format from the configuration
855855
return $this->config->item('rest_default_format');
856856
}
857857

0 commit comments

Comments
 (0)