-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Expose EntityPersister::count()
through EntityRepository::count()
#6003
Conversation
584dc0c
to
3a41091
Compare
3a41091
to
f384bb4
Compare
I personally don't like overloading the repositories with even more functionality, but this might actually be useful. Thoughts, @guilhermeblanco @beberlei @deeky666 @kimhemsoe? |
@@ -41,7 +41,7 @@ headline "Hello World" with the ID 1234: | |||
<?php | |||
$article = $entityManager->find('CMS\Article', 1234); | |||
$article->setHeadline('Hello World dude!'); | |||
|
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.
Please don't trim whitespace: it is in place due to RST here.
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.
Ok @Ocramius, I'll revert these changes.
I would probably have assumed this feature already existed if asked. From that perspective I think it makes for a good addition. Perhaps use a rebase --interactive to clean up the change then revert of whitespace changes to the docs. |
Sure @carnage, when the PR is ready to merge I'll perform a rebase. |
👍 that would avoid having to write a DQL query for a simple count (unless I'm completely wrong?) |
Yes @mnapoli, this is the intended goal. |
case 4: | ||
return $this->$method(array($fieldName => $arguments[0]), $arguments[1], $arguments[2], $arguments[3]); | ||
|
||
default: |
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.
Do you know if this statement is here intentionally (just for the comment) or if this can be removed?
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 a bug.
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.
Removed.
LGTM 👍 (would use a +1 thing but I'm on mobile, sorry) |
case 3: | ||
return $this->$method(array($fieldName => $arguments[0]), $arguments[1], $arguments[2]); | ||
|
||
case 4: |
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.
If we support only PHP 5.6+, then we can simply do return $this->$method([$fieldName, $arguments[0]), ...array_slice($arguments, 1))
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.
And yep, we only support 5.6+
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'll apply this on merge: merging and moving forward from master
myself :-)
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.
Should I squash now then?
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.
Nope: already checked out locally and took ownership of the branch. Relax, sit back and have a 🍺
|
||
$fieldName = lcfirst(\Doctrine\Common\Util\Inflector::classify($by)); | ||
|
||
if ($this->_class->hasField($fieldName) || $this->_class->hasAssociation($fieldName)) { |
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.
Should throw an exception when this is not true: move the exception throwing up :-)
@phansys merged, thanks! |
@teohhanhui sorry, our docs are indeed terribly versioned, as it stands (website publishes current |
Feature added in doctrine#6003
This is such an unexpected BC-break for those who implemented this method on their own like I did... |
Adding new public method is not a BC break per se. BC break is an unexpected change of behavior or existing API. Even Symfony, known for its BC promise, won't give you guarantee when it comes to extending a class and adding new methods: https://symfony.com/doc/current/contributing/code/bc.html |
@Majkl578 , okay. But extending |
I don't see how this is a BC break: yes, it raises a warning if you subclassed and had different signature, but that makes it easy to migrate whilst maintaining it working. And yes, that basically clarifies my initial doubts: no more |
TODO: