From ce1768fb74d4585ff3f09fc6ff5cdd0b9b3195ec Mon Sep 17 00:00:00 2001 From: ig0rb Date: Fri, 13 Dec 2019 19:46:13 +0100 Subject: [PATCH] In CodeIgniter3 Router class methods was changed, if CI3 is detected the new methods are used --- src/Controller.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Controller.php b/src/Controller.php index 3dcb76a..b236bd6 100644 --- a/src/Controller.php +++ b/src/Controller.php @@ -184,7 +184,11 @@ public function listen() // Worker command builder // Be careful to avoid infinite loop by opening listener itself $workerAction = 'work'; - $route = $this->router->fetch_directory() . $this->router->fetch_class() . "/{$workerAction}"; + if($this->_isCI3()) { + $route = $this->router->directory . $this->router->class . "/{$workerAction}"; + } else { + $route = $this->router->fetch_directory() . $this->router->fetch_class() . "/{$workerAction}"; + } $workerCmd = "{$this->phpCommand} " . FCPATH . "index.php {$route}"; // Static variables @@ -338,7 +342,11 @@ public function launch($action='listen') $logPath = '/dev/null'; // Action command builder - $route = $this->router->fetch_directory() . $this->router->fetch_class() . "/{$action}"; + if($this->_isCI3()) { + $route = $this->router->directory . $this->router->class . "/{$action}"; + } else { + $route = $this->router->fetch_directory() . $this->router->fetch_class() . "/{$action}"; + } $cmd = "{$this->phpCommand} " . FCPATH . "index.php {$route}"; // Check process exists @@ -570,6 +578,19 @@ protected function _isPidAlive($pid) return ((function_exists('posix_getpgid') && posix_getpgid($pid)) || file_exists("/proc/{$pid}")) ? true : false; } + /** + * Check if i'm using codeingniter 3 + * + * @return boolean + */ + protected function _isCI3() { + $ci_version = explode('.', CI_VERSION); + if ($ci_version[0] >= 3) { + return true; + } + return false; + } + /** * Check if OS is Linux *