문제가 발생하여 해결 방법을 모르겠습니다.Codeigniter 컨트롤러 이름과 개체 이름 충돌
나는 방법 내가 내 컨트롤러에 반환 된 푸셔 객체를 var_dump()
때 new Pusher()
객체
require 'vendor/autoload.php';
class Pusher_model extends CI_Model
{
public $options;
/**
*
*/
public function __construct()
{
$this->config->load('api_config');
$this->options = array(
$this->config->item('pusher_cluster'),
$this->config->item('pusher_is_encrypted')
);
}
/**
*
*/
public function newPusher()
{
return new Pusher(
$this->config->item('pusher_public_key'),
$this->config->item('pusher_secret_key'),
$this->config->item('pusher_api_id'),
$this->options
);
}
}
를 인스턴스화하는 방법과 모델 Pusher_model
이 Auth
class Pusher extends MX_Controller
{
/**
*
*/
public function auth()
{
$this->load->model('pusher/Pusher_model');
$p = $this->Pusher_model->newPusher();
var_dump($p);die;
}
}
와 컨트롤러 Pusher
이 ...
var_dump($p)
,
나는 ... 결과로 나를 인스턴스화 된 객체와 컨트롤러 자체에가는 이름 충돌이 믿고 리드
object(Pusher)#24 (2) {
["autoload"]=>
array(0) {
}
["load"]=>
object(MY_Loader)#25 (13) {
["_module":protected]=>
string(6) "pusher"
["_ci_plugins"]=>
array(0) {
}
["_ci_cached_vars"]=>
&array(0) {
}
["_ci_ob_level":protected]=>
int(1)
["_ci_view_paths":protected]=>
&array(1) {
["C:\xampp\htdocs\php\twocan\twocan_beta\App\views\"]=>
bool(true)
}
["_ci_library_paths":protected]=>
&array(2) {
[0]=>
string(43) "C:\xampp\htdocs\php\twocan\twocan_beta\App\"
[1]=>
string(43) "C:\xampp\htdocs\php\twocan\twocan_beta\Sys\"
}
["_ci_model_paths":protected]=>
&array(2) {
[0]=>
string(58) "C:\xampp\htdocs\php\twocan\twocan_beta\App\modules/pusher/"
[1]=>
string(43) "C:\xampp\htdocs\php\twocan\twocan_beta\App\"
}
["_ci_helper_paths":protected]=>
&array(2) {
[0]=>
string(43) "C:\xampp\htdocs\php\twocan\twocan_beta\App\"
[1]=>
string(43) "C:\xampp\htdocs\php\twocan\twocan_beta\Sys\"
}
["_ci_classes":protected]=>
&array(15) {
["benchmark"]=>
string(9) "Benchmark"
["hooks"]=>
string(5) "Hooks"
["config"]=>
string(6) "Config"
["log"]=>
string(3) "Log"
["utf8"]=>
string(4) "Utf8"
["uri"]=>
string(3) "URI"
["router"]=>
string(6) "Router"
["output"]=>
string(6) "Output"
["security"]=>
string(8) "Security"
["input"]=>
string(5) "Input"
["lang"]=>
string(4) "Lang"
["loader"]=>
string(6) "Loader"
["session"]=>
string(7) "Session"
["form_validation"]=>
string(15) "Form_validation"
["model"]=>
string(5) "Model"
}
["_ci_models":protected]=>
&array(1) {
[0]=>
string(12) "Pusher_model"
}
["_ci_helpers":protected]=>
&array(5) {
["url_helper"]=>
bool(true)
["html_helper"]=>
bool(true)
["security_helper"]=>
bool(true)
["language_helper"]=>
bool(true)
["form_helper"]=>
bool(true)
}
["_ci_varmap":protected]=>
&array(2) {
["unit_test"]=>
string(4) "unit"
["user_agent"]=>
string(5) "agent"
}
["controller"]=>
*RECURSION*
}
}
을 전체 컨트롤러 '푸셔'를 얻을.
Q :
가 어떻게 내 컨트롤러의 이름을 변경하지 않고이 충돌을 해결하거나 내가 그 컨트롤러를 통해 인스턴스화 어떤 물체에 다른 컨트롤러 이름을 사용해야합니까?
와우, 멋진 Jens, 건축에 대한 조언 주셔서 감사합니다. 잠시 동안 나는 컨트롤러 웹 소켓의 이름을 바꾸었지만 구현은 좋은 생각입니다. –
다행히 도울 수 있어요 :) –