Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In CodeIgniter3 Router class methods was changed, if CI3 is detected … #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
*
Expand Down