Skip to content
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

set endpoint_aliases to specify fixed aliases for exposed dataobjects #80

Merged
merged 17 commits into from
Jul 14, 2019

Conversation

sanderha
Copy link
Contributor

@sanderha sanderha commented Jul 3, 2019

No description provided.

Copy link
Contributor

@ScopeyNZ ScopeyNZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've suggested PHP 7.1 typing as you've used the null coalesce operator. I also think that "$endpoint" isn't really an appropriate parameter name. The method is resolving the endpoint from the class name. I would propose a method signature like:

resolveEndpoint(string $className): string

Also I think that ->unsanitiseClassName should only be called on the class name and not the "aliased endpoint" if that is being used.

Thanks for this contribution! It's a great idea.

src/RestfulServer.php Outdated Show resolved Hide resolved
src/RestfulServer.php Outdated Show resolved Hide resolved
src/RestfulServer.php Outdated Show resolved Hide resolved
sanderha and others added 3 commits July 8, 2019 08:34
Co-Authored-By: Guy Marriott <guy@scopey.co.nz>
Co-Authored-By: Guy Marriott <guy@scopey.co.nz>
Co-Authored-By: Guy Marriott <guy@scopey.co.nz>
@sanderha
Copy link
Contributor Author

sanderha commented Jul 8, 2019

@ScopeyNZ Thanks for your reply!

Indeed what you've wrote makes sense. Would it be best to also change the null coalesce operator for backwards compatability?

Also I'll get that method and param name renamed asap

@sanderha
Copy link
Contributor Author

sanderha commented Jul 8, 2019

@ScopeyNZ Please have another look when you have the time :-)

@ScopeyNZ
Copy link
Contributor

Thanks @sanderha . Looks like past me gave some bad feedback.

Looks like you were correct in the first place where resolveEndpoint was actually resolving a class name 🤦‍♂ . I guess I got confused that the URL param is labelled ClassName. I'm sorry for messing you around a bit here but perhaps we should actually have it as

public function resolveClassName(HTTPRequest $request): string

All you would have to add is $request->param('ClassName') in that method and update where it's called. I think that's probably more helpful for a developer looking to extend as they can inspect other parts of the request to determine what classname should be returned (if they want).

Sorry again for past me 😅

@sanderha
Copy link
Contributor Author

Ah, yeah using simply $request as the param makes sense.
Any specific reason why you want it to be public method?

@ScopeyNZ
Copy link
Contributor

Ah, nope. Just habit I guess. It should probably be protected.

@sanderha
Copy link
Contributor Author

Updated it again :-)

Copy link
Contributor

@ScopeyNZ ScopeyNZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Sorry for all the crazy back on forth - that's my fault 😧

Just one last little thing but then it's ready to merge!

src/RestfulServer.php Outdated Show resolved Hide resolved
@NightJar
Copy link
Contributor

NightJar commented Jul 12, 2019

Also please be sure to run phpcs over the code before committing! :)
If you don't have this locally, you can get it on the project you're testing your changes on with composer require --dev squizlabs/php_codesniffer ^3 and run ../../bin/phpcs from within this module's install dir (vendor/silverstripe/restfulserver)

"squizlabs/php_codesniffer": "^3.0",

https://travis-ci.org/silverstripe/silverstripe-restfulserver/jobs/557159932#L626

@sanderha
Copy link
Contributor Author

@NightJar Alright changed some docblocks to satisfy code sniffer! :)

@ScopeyNZ
Copy link
Contributor

I've just pushed an update to drop PHP 5.6 and 7.0 from builds. That should get travis happy.

@ScopeyNZ ScopeyNZ merged commit 0b734c2 into silverstripe:master Jul 14, 2019
Copy link
Contributor

@robbieaverill robbieaverill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you've introduced PHP 7 only syntax. This module still supports PHP 5.6. We can bump this to require SilverStripe 4.5 which is PHP 7 only, but I don't see the benefit. Would you mind reverting those changes please?

@ScopeyNZ
Copy link
Contributor

That was my suggestion 😅 .

@robbieaverill
Copy link
Contributor

#82 has come up now asking to revert the PHP 7 syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants