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 more posts authors #478
Conversation
// in different files. This reference has been added in the UserFixtures | ||
// file and it contains an instance of the User entity. | ||
$post->setAuthor($this->getReference('jane-admin')); | ||
// This ensures that the first post is written by Jane Doe |
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.
Why do you need that the first Post belongs to Jane?
$crawler->filter('body#admin_post_index #main tbody tr'), | ||
$this->assertGreaterThanOrEqual( | ||
1, | ||
$crawler->filter('body#admin_post_index #main tbody tr')->count(), |
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.
Since authors are randomly assigned, each time the fixtures are loaded this test would fail (depending on the authenticated user)
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.
@yceruto, Jane Doe has at least one post, so test should pass.
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.
Ooh! GreaterThanOrEqual
you're right, this answers my first question too (Why do you need that the first Post belongs to Jane
)
FROM AppBundle:Post p | ||
JOIN p.author a |
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.
AFAIK this shouldn't improved nothing, Doctrine hydrates the author without an extra query.
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.
@yceruto, I think you're wrong. See http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html#joins
A join (be it an inner or outer join) becomes a “fetch join” as soon as fields of the joined entity appear in the SELECT part of the DQL query outside of an aggregate function.
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, I think it's necessary for multiple users then 👍
Why not just use https://github.com/nelmio/alice. |
I wouldn't add the Alice bundle for such a simple demo application as this one. We want to showcase the main Symfony features ... but not turn this into a too large and too slow app. |
It took me a long time, but this is finally merged! Thanks @voronkovich |
This PR was merged into the master branch. Discussion ---------- Add more posts authors For now we have only one admin: Jane Doe. Latest posts with more than one author look more naturally. Commits ------- c891805 Update fixtures eafb89e Updated the user fixtures c366c05 Join posts authors when quering latests posts 72bddba Add more posts authors
For now we have only one admin: Jane Doe. Latest posts with more than one author look more naturally.