Skip to content

Commit 9d85c10

Browse files
Chris KacerguisChris Kacerguis
authored andcommitted
moved preflight checks to their own method
1 parent ef28253 commit 9d85c10

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

application/libraries/REST_Controller.php

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -381,21 +381,7 @@ public function __construct($config = 'rest')
381381
{
382382
parent::__construct();
383383

384-
// Disable XML Entity (security vulnerability)
385-
libxml_disable_entity_loader(TRUE);
386-
387-
// Check to see if PHP is equal to or greater than 5.4.x
388-
if (is_php('5.4') === FALSE)
389-
{
390-
// CodeIgniter 3 is recommended for v5.4 or above
391-
throw new Exception('Using PHP v'.PHP_VERSION.', though PHP v5.4 or greater is required');
392-
}
393-
394-
// Check to see if this is CI 3.x
395-
if (explode('.', CI_VERSION, 2)[0] < 3)
396-
{
397-
throw new Exception('REST Server requires CodeIgniter 3.x');
398-
}
384+
$this->preflight_checks();
399385

400386
// Set the default value of global xss filtering. Same approach as CodeIgniter 3
401387
$this->_enable_xss = ($this->config->item('global_xss_filtering') === TRUE);
@@ -600,6 +586,29 @@ public function __destruct()
600586
}
601587
}
602588

589+
/**
590+
* Checks to see if we have everything we need to run this library.
591+
*
592+
* @author Chris Kacerguis
593+
* @access protected
594+
* @return Exception
595+
*/
596+
protected function preflight_checks()
597+
{
598+
// Check to see if PHP is equal to or greater than 5.4.x
599+
if (is_php('5.4') === FALSE)
600+
{
601+
// CodeIgniter 3 is recommended for v5.4 or above
602+
throw new Exception('Using PHP v'.PHP_VERSION.', though PHP v5.4 or greater is required');
603+
}
604+
605+
// Check to see if this is CI 3.x
606+
if (explode('.', CI_VERSION, 2)[0] < 3)
607+
{
608+
throw new Exception('REST Server requires CodeIgniter 3.x');
609+
}
610+
}
611+
603612
/**
604613
* Requests are not made to methods directly, the request will be for
605614
* an "object". This simply maps the object and method to the correct

0 commit comments

Comments
 (0)