-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add default_order option to doctrine processors #13
Conversation
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.
Hey there @alekitto!
Thank you for this PR. Just left some comments 😄
@@ -14,7 +14,7 @@ class StringToExpresionTransformer implements DataTransformerInterface | |||
|
|||
public function __construct(?Grammar $grammar = null) | |||
{ | |||
$this->grammar = $grammar ?? new Grammar(); | |||
$this->grammar = $grammar ?? self::getGrammar(); |
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.
Instead of having in this transformer the static method getGrammar()
, what do you think about making Grammar
class singleton?
In this way we can have Grammar::getInstance()
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.
👍
$value = '$order('.$value.')'; | ||
} | ||
|
||
$grammar = new Grammar(); |
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.
Instead of new Grammar()
I would use the Grammar::getInstance()
. Probably it could be interesting overriding that grammar. Using $this->grammar
(and giving possibility to override that with a setter setGrammar(?Grammar $grammar)
) could make this possible (like in the transformer above)
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.
Done
/** | ||
* @dataProvider provideParamsForDefaultOrder | ||
*/ | ||
public function testShouldOrderByDefaultField(bool $exception, bool $valid, string $defaultOrder): void |
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 would prefer to have these tests separated instead a single.
Something like testOrderByDefaultFieldShouldThrowOnInvalidOptions
and testOrderByDefaultFieldShouldWork
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.
Done
/** | ||
* @dataProvider provideParamsForDefaultOrder | ||
*/ | ||
public function testShouldOrderByDefaultField(bool $exception, bool $valid, string $defaultOrder): void |
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.
Same as the ORM one: I would prefer to have these tests separated instead a single.
Something like testOrderByDefaultFieldShouldThrowOnInvalidOptions
and testOrderByDefaultFieldShouldWork
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.
Done
76c9265
to
4f4b65b
Compare
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.
Thank you, @alekitto!
Implement
default_order
option.Fix #9