-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
forgot to add the extratokens variable to the serve function #61
Conversation
Added $extratokens variable to serve method
Thanks. Good idea, I think I’m going to re-factor this so tokens can be added before the |
Based on the examples given on the wiki, the code is now broken. If I don't pass extratokens into the "serve" extratokens defaults to null and throws an error when attempting the foreach loop. It seems to me that what is trying to be accomplished here can already be done with the current (pre: merge) of Toro. I would suggest removing this new code and putting it into your own "HandlerClass" using the ToroHooks as illustrated here: https://gist.github.com/jmashburn/6704746 |
This code should have been two separate commits. |
Ok, I'll watch for the change. |
My bad. I’ve not been as sharp as I could have been the last couple of days as I’ve picked up a bug. I’ve created a new branch called develop with the broken code, and rolled back master to pre-Pull Request. I’ll work on adding the “extra tokens” functionality to Toro’s core in a more elegant manner. @jmashburn From what I understand, @small1 wanted to check if there was a handler that matched a passed URL. |
@martinbean Did you see the Gist I added earlier in the thread? Seems like a perfect example of the ToroHooks passing the routes into the callbacks which can be assigned in the HandlerClass and checked there or am I not seeing the bigger picture? |
@jmashburn I hadn’t. It looks clean and tidy, but think @small1 was wanting to add his own tokens that could be used in route patterns, like :number etc. Although saying this, I would do pretty much what you do in your Gist, doing the condition check within my handler. M |
I created a branch at https://github.com/jmashburn/ToroPHP/tree/Tokens with my attempt at tokens/routes. Here is an example how it works. < https://gist.github.com/jmashburn/6708647 > You can add additional routes/tokens in the before_request callback, or statically, before the serve call or a combination of any/all. There is minimal code changes in the core. Function's like has hasHandlerFor can be put in callbacks and parse the routes from the params that are passed in. What do you think? |
I was thinking of moving the |
Check my branch. I''ve already added that. https://github.com/jmashburn/ToroPHP/tree/Tokens |
Added $extratokens to the server() fuction.
Sample usage:
Toro::serve(array(
"/" => "MainPageHandler",
"/users" => "UsersHandlerShow",
"/users/:userid/edit" => "UsersHandlerEdit",
), array(':userid' => CurrentUserID())); // CurrentUserID() in this case returns the userid of the currently logged in user.