-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Implement new api:routes command. #31
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
Conversation
@@ -184,4 +187,13 @@ protected function registerMiddlewares() | |||
$this->app->middleware('Dingo\Api\Http\Middleware\RateLimit', [$this->app]); | |||
} | |||
|
|||
protected function registerCommands() | |||
{ | |||
$this->app['api.routes'] = $this->app->share(function($app) { |
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.
Bind it in the container as dingo.api.command.routes
.
This looks really solid @hskrasek. Only things I'm going to want you to change are to use tabs instead of spaces, opening brace should be on a new line, use the literal array syntax And don't worry about testing. 😄 |
Why does this not use Symfony's Table helper like Artisan's command route ? That'd be much more solid |
It does, doesn't it? $this->table = $this->getHelperSet()->get('table'); |
It basically is an exact clone of the Artisan routes command. With the addition of maybe one function, and small changes here and there :P. @jasonlewis I shall make those changes now. |
Ah yeah sorry I'm used to Symfony 2.5's helpers so I was looking for the |
Cheers @hskrasek, just refer to some of the other files for the style. 👍 |
Question then though: if dingo/api is meant for Laravel only, why not just extend |
@Anahkiasen I had tried that and ran into some errors at the time (can't remember the exact error, I've slept since then). I might look into extending the |
@Anahkiasen Plus I think some sort of separation is required, especially if you have many API routes and many regular routes. |
No I meant using the core code of it but still just displaying the API routes, just that when Laravel does update to 2.5's Table helper, you'd inherit that too. Since Laravel 4.2 comes with 2.5 components it's likely to happen soon. |
…the ApiRoutesCommand
@jasonlewis Style changes pushed up now. And I believe @Anahkiasen is saying instead of |
Yeah that's what I meant |
Ah yeah, makes sense, take a look and see if it would be possible @hskrasek. Otherwise I'll merge this in tomorrow (my time). |
return new ApiRoutesCommand($app['router']); | ||
}); | ||
|
||
$this->commands('api.routes'); |
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.
This will need to be updated as well to reflect the new container binding.
@jasonlewis I was able to change up the command to extend the RoutesCommand. Everything seems to be in working order. |
aw yiss, really waiting for this. |
I haven't tested this, since I didn't even know the options existed until looking at the source, but this command should also support the filtering capabilities that the base Artisan routes command has. |
Woot! No problem, now to find something else to try and contribute to in this package :P |
Below is my implementation of the
api:routes
command. Functions basically the same as the baseroutes
command but with different data.No tests included, since I have no idea how you would even test Artisan commands.