• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Basic question - need some pointers on extending a library

#1
Or a definitive "you can't do that".

I'm using the HMVC libraries for CI and have an "admin" module that I've been using for several years.  Within that module is an "authentication" library that I use all over the place.

I've got some app-specific code that's been pushed down into the module and I'd like to decouple the two.

To that end I've created an AppAuthentication class that my app loads which extends the module Authentication.  I've got appropriate functions overloaded in my version so that I can perform app-specific operations after login and logout.

The problem is that the module still wants to load the base version and so my overload never gets called.

How can I get the module to load my class without having app-specific code down in the module?

Would I need to pass an instance of my class down to the authentication module and mod it use use that?

Or am I asking for too much?

Sorry for the basic question but there are still swaths of PHP I'm not familiar with.
Reply

#2
Looks like I might have figured out a method for this.

I put the module's class in the namespace 'admin' and left everything else in the module alone.
I require_once that class and extend admin\Authentication and name my class Authentication.

Since everything is just loading an "Authentication" class, they end up with my subclass
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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