• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Routing DB pages

#11
Sorry for the late reply @weblogics.

Your example looks very interesting. I will look at inserting a similar solution.
Thanks for your feedback Smile
Reply

#12
(10-08-2015, 07:54 AM)Martin7483 Wrote: Sorry for the late reply @weblogics.

Your example looks very interesting. I will look at inserting a similar solution.
Thanks for your feedback Smile

I'm working on a combined solution as your's also looks a better way of modifying the request to the routing rather than relying on an include into the routes.php function. To be honest i've never really looked at creating a MY_Router, but it seems like a logical progression.

I'm also having similar issues getting to an eligant and scalable solution as i'm sure others are, it would be good to get to a solution with other guys on this forum as well. Happy to setup and collab on GitHub with you as i'm sure this benefits all of us reading this post not just us two.
Reply

#13
I didn't really take a look at this earlier for one reason or another, but here's my initial feedback on the MY_Router class:

- Match the signature of the parent's constructor and pass the argument to the parent so you don't lose functionality in the router:

PHP Code:
public function __construct($routing NULL)
{
    
log_message('debug'"Class ".get_class($this)." Initialized.");
    
parent::__construct($routing);


- The get_class($this) is not really necessary here unless you plan on further extending MY_Router. It's a great idea for things like MY_Controller and MY_Model, where you could potentially have hundreds of extending classes, but an extension of MY_Router is going to be rare enough that it can write its own log_message() call for initialization (and I would make this an 'info' call to match the call in CI_Router, but that's up to you).

- You'll have to update this for 3.0.2, which shouldn't be too painful and hopefully won't mess anything up. This is what always makes me step back from overwriting existing methods and try to think about another way to do it. In this case, I'm still not completely sure, but after running it through a diff against the 3.0.1 router, I can see that you did tread lightly, and I haven't found a way, yet, to do the same thing while overriding fewer methods.
Reply

#14
(10-09-2015, 06:33 AM)mwhitney Wrote: I didn't really take a look at this earlier for one reason or another, but here's my initial feedback on the MY_Router class:

- Match the signature of the parent's constructor and pass the argument to the parent so you don't lose functionality in the router:




PHP Code:
public function __construct($routing NULL)
{
 
   log_message('debug'"Class ".get_class($this)." Initialized.");
 
   parent::__construct($routing);


- The get_class($this) is not really necessary here unless you plan on further extending MY_Router. It's a great idea for things like MY_Controller and MY_Model, where you could potentially have hundreds of extending classes, but an extension of MY_Router is going to be rare enough that it can write its own log_message() call for initialization (and I would make this an 'info' call to match the call in CI_Router, but that's up to you).

- You'll have to update this for 3.0.2, which shouldn't be too painful and hopefully won't mess anything up. This is what always makes me step back from overwriting existing methods and try to think about another way to do it. In this case, I'm still not completely sure, but after running it through a diff against the 3.0.1 router, I can see that you did tread lightly, and I haven't found a way, yet, to do the same thing while overriding fewer methods.

- Changed the constructor so it now matches the parent constructor.

- get_class is me being a bit lazy when adding a log message. I can just copy and paste and the corret class name is logged. I like to log all classes that are called so I can see what is going on when debugging and searching for problems.

Reading the changelog for 3.0.2 I only found this regarding the Router class

Quote:Fixed a bug (#4109) - Routing to default_controller didn’t work when enable_query_strings is set to TRUE.

So I think I only need to update the _set_routing method with the fixed one and it should be good to go.
Reply

#15
I have just been upgrading to 3.0.2 and all is good.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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