-
Notifications
You must be signed in to change notification settings - Fork 2
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
Break the routes #38
Break the routes #38
Conversation
…pp rather than arrays.
Note: this completely borks named routes (and therefore all methods that work with routes based on their name, which happen to be fantastic methods), so a further commit which fixes that is coming later today. This will add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small stuff comments.
Question though: if this breaks named routes, how come test suite passes? 😜
CHANGELOG.md
Outdated
@@ -67,6 +67,7 @@ __Backwards-incompatible Changes__ | |||
- `\Parable\Routing\Route` has lost the ability to use typed params. Too much code for too little gain. If you need typed parameters, I suggest you figure something out for yourself. | |||
- `\Parable\Routing\Route` no longer supports `template` for the template path, but the more correctly named `templatePath` instead. Because of this, it now checks more strictly whether valid properties are set through the Routing array. `setDataFromArray()` attempts to call setters named like the properties. Any that are not available with a setter will throw an Exception. All properties are now also `protected`. | |||
- `\Parable\Routing\Router` now also supports adding a completely set-up `Route` object directly (or in an array), without having to pass them as arrays, through `addRoute()` and `addRoutes()`. These methods already existed, but those are now renamed to `addRouteFromArray()` and `addRoutesFromArray()`. | |||
- The default structure's `\Config\App` is now expected to extend the abstract base class `\Parable\Framework\Routing\AbstractRouting` and the old `Interfaces\Routing` interface has been removed. **This removes passing routes as arrays!**. See the new implementation, using the method calls on `\Parable\Framework\App` in the structure's `app/Routing/App.php_struct`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this line start with the following?
The default structure's
\Routing\App
(As seen in the struct file)
structure/app/Routing/App.php_struct
Outdated
/* | ||
* It's also possible to specify multiple methods to respond to. Also, callables. | ||
*/ | ||
$this->app->multiple(["GET", "POST"], "/callable", function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Request::METHOD_*
?
structure/app/Routing/App.php_struct
Outdated
], | ||
]; | ||
/* | ||
* Valid methods are GET/POST/PUT/PATCH/DELETE/OPTIONS. If a url matches but the method doesn't, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reference Request::METHOD_*
or Request::VALID_METHODS
constants?
@dmvdbrugge The tests still worked because it wasn't actively under test, but passively. That's why I've added some tests to check for both named routes and unnamed (which will generate a uniqid for it instead). |
Arrays are stupid. Now that there's
->get()
,->post()
, etc. available on\Parable\Framework\App
, it's much better to use those, especially since, as methods, they offer type hinting whereas the array method is far too loose and fragile.