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

support current user in Query Trait #309

Merged
merged 2 commits into from
Mar 16, 2016
Merged

support current user in Query Trait #309

merged 2 commits into from
Mar 16, 2016

Conversation

lenybernard
Copy link
Contributor

In some case like, we want to be able to filter the query according to the current user.
Now, we just need to have some BusinessEntity with a User relation and use :currentUser in the query input:

JOIN item.user WHERE u.id = :currentUser

@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @gregumo, @paulandrieux and @scrutinizer-auto-fixer to be potential reviewers

if (is_object($this->getCurrentUser())) {
$itemsQueryBuilder->setParameter('currentUser', $this->getCurrentUser()->getId());
} else {
throw new AccessDeniedException();
Copy link
Member

Choose a reason for hiding this comment

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

When the client is not logged, wouldn't be better showing blank instead of throwing an exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't able to find a case where we would like to have such a widget in an anonymous scope but why not.

To go further, I think we could just do not run the query if there is the :currentUser parameter and no user authenticated

lenybernard pushed a commit that referenced this pull request Mar 16, 2016
…y-trait

support current user in Query Trait
@lenybernard lenybernard merged commit 290846c into Victoire:master Mar 16, 2016
@lenybernard lenybernard deleted the feature/current-user-in-query-trait branch March 16, 2016 10:04
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.

3 participants