anandkunal / ToroPHP

Toro is a PHP router for developing RESTful web applications and APIs.
http://toroweb.org
MIT License
1.17k stars 173 forks source link

Implement static parameters in Handler methods #70

Open sergeylukin opened 10 years ago

sergeylukin commented 10 years ago

Introducing new feature. Shouldn't break any existing functionality. Inspired by what can be done with mod_rewrite:

RewriteRule ^something$  index.php?page_ID=15
sergeylukin commented 10 years ago

After playing with it I got to conclusion that it'd be more flexible to provide one array with all the parameters in key-value format instead of adding them one by one as separate key-less arguments as it may be necessary to fetch parameters by their key name to make sure that desired parameter is fetched and not anything else. An example could be a Base Handler Class that adds some generic Hook in the __constructor and it cannot guarantee that every Handler that extends it has a static parameter passed in it's route. In that case, verification functionality may be required to verify that specific static parameter has been passed before adding the Hook.

I'll submit a commit with the changes described above soon.