Ticket #722 (closed Feature Request: fixed)

Opened 4 months ago

Last modified 4 months ago

Replace _default/_remap to __call

Reported by: dlib Owned by: Shadowhand
Priority: minor Milestone: 2.2
Component: Core Version: SVN HEAD
Keywords: Cc:

Description (last modified by Shadowhand) (diff)

We can get rid of _default and _remap methods and instead implement a __call method in the Controller_Core class. This method triggers a 404 by default but you can override it in the page controllers to get _default or _remap like behaviour. It also means Kohana::instance doesn't need to do a method_exists check (or Reflection equivalent) and thus might gain a little speed. It also simplifies the Kohana::instance.

I included a patch before the Reflection change but with some changes it will also work with the Reflection class.

Attachments

kohana_core.txt (4.9 kB) - added by dlib 4 months ago.

Change History

Changed 4 months ago by dlib

Changed 4 months ago by Shadowhand

The only problem with this is that _remap takes precedence over *all* other methods, and _default takes *last* precedence when no suitable method can be found. That said, it seems silly to not use call. I'd like the rest of the devs opinions on this.

Changed 4 months ago by Shadowhand

  • status changed from new to closed
  • resolution set to wontfix

Won't fix, because of above comments.

Changed 4 months ago by dlib

  • status changed from closed to reopened
  • resolution deleted

The issue of _remap() is solved by leaving in a 'method_exists('remap')' as the only conditional but leave out the other checks for _default or the Router::$method. I think using php own's functionality here will be faster is more intuitive in this case.

Changed 4 months ago by Shadowhand

  • description modified (diff)

Okay, that makes sense. Here's what I'm seeing now:

  • _remap and _default are removed
  • _remap functionality is achieved by routes
  • No checks are made to determine if the method is valid
  • The controller method is called, __call is invoked, defaulting to a 404

This would eliminate the need to use reflection entirely.

Changed 4 months ago by Shadowhand

  • status changed from reopened to closed
  • resolution set to fixed

Fixed in r3280 and r3281.

Note: See TracTickets for help on using tickets.