• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about (extending) Controllers

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:
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:
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:
return (bool) $this->ci->session->userdata($identity);

However, this produces error which states that 'session' is not known.
If I do:
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?



Found it, after a lot of debugging Sad
The order of loading libraries was incorrect whereby Cpin2_rest overtook $this instance Sad

Just a quick thing from me:

$this->ci =& get_instance();

should be:

$this->ci = get_instance();


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.