Welcome Guest, Not a member yet? Register   Sign In
Question about (extending) Controllers
#1

[eluser]smilie[/eluser]
Hi all!

This is (most) probably a pure PHP question and not so much CI related. I am however stuck and would appreciate some help from you Smile

Oke, here we go (in steps):

1. Clean CI installation;
2. In a new Application directory placed:
Code:
abstract class CORE_Controller extends CI_Controller { ... }
This is loaded by all other controllers in the application folder.
3. Added REST Controller in the CI Core directory under libraries > Cpin2_rest.php:
Code:
class Cpin2_rest extends CI_Controller { ... }
4. Added Ion Auth library in application.

The problem.
Ion Auth library is getting an instance of CI in constuctor with:
$this->ci =& get_instance();

Then, in function logged_in() it does:
Code:
return (bool) $this->ci->session->userdata($identity);

However, this produces error which states that 'session' is not known.
If I do:
Code:
echo '<pre>'; print_r($this->ci); echo '</pre>'; exit;
I see that $this->ci is actually Rest controller and not CI_Controller.

So - where did I took a wrong turn and is Rest controller now primary controller?

Thanx!

Cheers,
Smilie
#2

[eluser]smilie[/eluser]
Found it, after a lot of debugging Sad
The order of loading libraries was incorrect whereby Cpin2_rest overtook $this instance Sad
#3

[eluser]Konfine[/eluser]
Just a quick thing from me:

$this->ci =& get_instance();

should be:

$this->ci = get_instance();

http://forrst.com/posts/CodeIgniter_and_...rences-tao




Theme © iAndrew 2016 - Forum software by © MyBB