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

Add default_order option to doctrine processors #13

Merged
merged 1 commit into from
Jan 24, 2020

Conversation

alekitto
Copy link
Member

Implement default_order option.

Fix #9

Copy link
Member

@massimilianobraglia massimilianobraglia left a 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();

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()

Copy link
Member Author

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();

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)

Copy link
Member Author

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

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

Copy link
Member Author

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@massimilianobraglia massimilianobraglia left a comment

Choose a reason for hiding this comment

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

Thank you, @alekitto!

@massimilianobraglia massimilianobraglia merged commit 198d453 into fazland:master Jan 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AQL: default ordering
2 participants