CodeIgniter Forums
Wick Problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Wick Problem (/showthread.php?tid=13982)



Wick Problem - El Forum - 12-14-2008

[eluser]dmyers[/eluser]
I decided to test WICK so I could add it to my bag of tricks but, the first test worked fine but, when I added it to my "generic" test application which has it's own controller (MY_Controller of course) I got a Fatal error:

Fatal error: Call to a member function checkaccess() on a non-object in /Applications/MAMP/htdocs/codeigniter170/system/application/libraries/MY_Controller.php on line 8

MY_Controller contains

class MY_Controller extends Controller {

function MY_Controller() {
parent::Controller();

$this->load->model('auth');
$this->auth->checkaccess();
}

}

So I am loading the controller right before the call?

If I call the welcome.php controller (via browser) which extends MY_Controller everything is fine.

but when I call more.php controller (via browser) which extends MY_Controller I get the error

class More extends MY_Controller {

function More() {
parent::MY_Controller();
}

function index() {
$this->load->library('Wick');

$this->wick->light('welcome/index');

//$data = array('pagename'=>'More');
//$this->load->view('welcome_message',$data);
}
}

class Welcome extends MY_Controller {

function Welcome() {
parent::MY_Controller();
}

function index() {
$data = array('pagename'=>'Welcome');
$this->load->view('welcome_message',$data);
}
}


class More extends MY_Controller {

function More() {
parent::MY_Controller();
}

function index() {
$this->load->library('Wick');

$this->wick->light('welcome/index');

//$data = array('pagename'=>'More');
//$this->load->view('welcome_message',$data);
}
}

I get the error.

The Auth model is

class Auth Extends Model {
function Auth() {
parent::Model();
$this->_auth = true;
}

function checkaccess() {
if ($this->_auth) return;
}
}

which just returns because access is good (true in this case)

Don Myers


Wick Problem - El Forum - 12-14-2008

[eluser]thinkigniter[/eluser]
[quote author="dmyers" date="1229314311"]I decided to test WICK so I could add it to my bag of tricks but, the first test worked fine but, when I added it to my "generic" test application which has it's own controller (MY_Controller of course) I got a Fatal error:

Fatal error: Call to a member function checkaccess() on a non-object in /Applications/MAMP/htdocs/codeigniter170/system/application/libraries/MY_Controller.php on line 8

MY_Controller contains

class MY_Controller extends Controller {

function MY_Controller() {
parent::Controller();

$this->load->model('auth');
$this->auth->checkaccess();
}

}

So I am loading the controller right before the call?

If I call the welcome.php controller (via browser) which extends MY_Controller everything is fine.

but when I call more.php controller (via browser) which extends MY_Controller I get the error

class More extends MY_Controller {

function More() {
parent::MY_Controller();
}

function index() {
$this->load->library('Wick');

$this->wick->light('welcome/index');

//$data = array('pagename'=>'More');
//$this->load->view('welcome_message',$data);
}
}

class Welcome extends MY_Controller {

function Welcome() {
parent::MY_Controller();
}

function index() {
$data = array('pagename'=>'Welcome');
$this->load->view('welcome_message',$data);
}
}


class More extends MY_Controller {

function More() {
parent::MY_Controller();
}

function index() {
$this->load->library('Wick');

$this->wick->light('welcome/index');

//$data = array('pagename'=>'More');
//$this->load->view('welcome_message',$data);
}
}

I get the error.

The Auth model is

class Auth Extends Model {
function Auth() {
parent::Model();
$this->_auth = true;
}

function checkaccess() {
if ($this->_auth) return;
}
}
[/quote]
Is
Code:
$this->_auth
refering to a variable that is not defined?
Try
Code:
class Auth Extends Model {
var $_auth = '';....
Also try changing
Code:
class Auth Extends Model {
to
Code:
class Auth extends Model {



Wick Problem - El Forum - 12-14-2008

[eluser]dmyers[/eluser]
Ok I made the changes

class Auth extends Model {
var $_auth = '';

function Auth() {
parent::Model();
$this->_auth = true;
}

function checkaccess() {
if ($this->_auth) return;
}
}

But that didn't help. Still getting.

Fatal error: Call to a member function checkaccess() on a non-object in /Applications/MAMP/htdocs/codeigniter170/system/application/libraries/MY_Controller.php on line 8

thank you for the reply thou.

Don -


Wick Problem - El Forum - 12-14-2008

[eluser]thinkigniter[/eluser]
Have you set
Code:
$config['subclass_prefix'] = 'MY_';
in your config file?

What is on line 8 on MY_Controller?


Wick Problem - El Forum - 12-14-2008

[eluser]dmyers[/eluser]
[quote author="thinkigniter" date="1229326197"]Have you set
Code:
$config['subclass_prefix'] = 'MY_';
in your config file?

What is on line 8 on MY_Controller?[/quote]


$this->bol = $this->auth->checkaccess();

checkaccess() on a non-object

Doesn't this mean the system thinks auth is not a object.

Config is set to

$config['subclass_prefix'] = 'MY_';

the extended subclass works normally just not when WICK calls the controller.

BTW Wick provides a method for loading and rendering one controller from within another controller. (from the wiki text)

http://codeigniter.com/wiki/Wick/

http://code.google.com/p/incendiary/downloads/detail?name=wick-0.91.zip


Wick Problem - El Forum - 12-14-2008

[eluser]thinkigniter[/eluser]
Code:
$this->bol = $this->auth->checkaccess();
refers to a variable $bol which, as before, is set right after you create the class e.g.
Code:
class Auth extends Model {
  var $_auth = '';
Is this variable set?


Wick Problem - El Forum - 12-14-2008

[eluser]dmyers[/eluser]
[quote author="thinkigniter" date="1229327511"]
Code:
$this->bol = $this->auth->checkaccess();
refers to a variable $bol which, as before, is set right after you create the class e.g.
Code:
class Auth extends Model {
  var $_auth = '';
Is this variable set?[/quote]


Did I do this right? I declared the variable line 2 var $_auth = ''; and then set it to true on this line $this->_auth = true;

Did I do that right?

class Auth extends Model {
var $_auth = '';

function Auth() {
parent::Model();
$this->_auth = true;
}

function checkaccess() {
if ($this->_auth) return;
}
}


then in MY_Controller I load the class/object with this $this->load->model('auth'); and then call the newly loaded/created object with this? $this->bol = $this->auth->checkaccess();

class MY_Controller extends Controller {
var $bol = null;

function MY_Controller() {
parent::Controller();

$this->load->model('auth');
$this->bol = $this->auth->checkaccess();
}

}

Did I do everything right?

Don ---


Wick Problem - El Forum - 12-22-2008

[eluser]Emanuel01[/eluser]
Hey I have that error too have you find a solution ?


Wick Problem - El Forum - 12-22-2008

[eluser]dmyers[/eluser]
[quote author="Emanuel01" date="1229998849"]Hey I have that error too have you find a solution ?[/quote]

No, no one has replied and I have not found a work around at this time.

DMyers