-
Notifications
You must be signed in to change notification settings - Fork 693
FOSRestController is now a trait and not longer a class extending from the core Controller class #1207
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
41e0181
to
4aafa19
Compare
👍 As PHP 5.4 is required. |
I'm wondering if it wouldn't be better to suffix its name with |
yeah .. was pondering this as well |
And IMO we should create a last release for the 1.* branch with bc layers to help to migrate to FOSRestBundle 2.0. |
not sure if its worth it .. I mean we have tons of open bugs/enhancement tickets .. at this point moving to 2.0 should not take all too long .. what does make sense is to maybe invest some more time into a migration guide |
c9a3762
to
7825c35
Compare
@@ -16,6 +16,7 @@ This document will be updated to list important BC breaks and behavioral changes | |||
* Removed ``callback_filter`` configuration option for the jsonp_handler | |||
* ``exception_wrapper_handler`` is now the name of a service and not the name of a class | |||
* removed all ``.class`` parameters, instead overwriting services via explicit Bundle configuration is preferred | |||
* ControllerTrait is now a trait and not longer a class extending from the core Controller class |
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 is not clear, imo include the new and the old name would be clearer.
7825c35
to
cd331d8
Compare
*/ | ||
abstract class FOSRestController extends Controller | ||
trait ControllerTrait |
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.
I think that this trait must extend the ContainerAwareTrait
as it can't work without it.
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.
Another solution would be to add an abstract method get
.
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.
well the trait falls back to using the magic get()
method .. but it can work without it ..
I am not quite sure how to best approach this .. maybe provide two traits .. ?
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.
Oops look too fast...
If there are two traits, the problem will be the same (moreover get
belongs to Controller
) ...
You can maybe check if the get
method exists on $this
or if $this
is an instance of Controller
.
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.
i fixed it by using $this->container->get()
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.
👍
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.
Finally, I'm wondering if two traits it's not too complicated to use...
Can't we just check if $this
is an instance of ContainerAwareInterface
or if $this->viewHandler
is defined and otherwise throw an exception?
675cdb6
to
f27465f
Compare
/** | ||
* Get the ViewHandler. | ||
* | ||
* @@param View $view |
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.
there is a typo here that I need to fix
f27465f
to
2be0336
Compare
To fix the tests one needs to do the following, which sucks big time as it basically means the trait isn't a logical unit anymore but requires other things that I cannot express with code :-/
|
Note even if we would change the core |
ok changing to use
Note technically it is sufficient to add the tl;dr: trait properties should always come with a getter method |
What about doing something like https://github.com/FriendsOfSymfony/FOSRestBundle/compare/master...Ener-Getick:CONTROLLER?expand=1 ? |
@Ener-Getick at the end of the day it still relies on a property that is no where defined in the trait or the contract defined by the trait. will see what happens with the ticket I opened on symfony core. |
* | ||
* @author Lukas Kahwe Smith <smith@pooteeweet.org> | ||
*/ | ||
trait ContainerAwareControllerTrait |
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.
refactor this to be a base class, ie. keep the existing name FOSRestController
76a649b
to
f5bbe57
Compare
aee479f
to
2393d31
Compare
ok .. keeping FOSRestController and just introducing ControllerTrait .. ready for final review. |
* | ||
* @param ViewHandlerInterface $viewhandler | 2D7E||
*/ | ||
protected function setViewHandler(ViewHandlerInterface $viewhandler) |
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.
IMO this should be public to allow setter injection
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.
agreed
Except my last comment, sounds good to me 👍. |
8ee4666
to
26c5bc2
Compare
@Ener-Getick fixed |
…r controllers instead of extending ``FOSRestController``
26c5bc2
to
7970b0c
Compare
FOSRestController is now a trait and not longer a class extending from the core Controller class
No description provided.