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

retrieve entities only if exist and DO NOT throw error if not found #7

Merged
merged 3 commits into from
Feb 16, 2015

Conversation

nedimdzendzo
Copy link
Contributor

Please have a look and let me know what do you think

@jordonsc
Copy link
Member

There's a couple things wrong here:

  • You've changed the logic of the retrieve() function, existing code that relies on the retrieve() function throwing an exception (or expecting a valid result) will now fail
  • Your return types are inconsistent (and your DocBlock's lie about it)

Instead of changing the logic of retrieve(), rather add a new function to the EntityManager say retrieveEntityOrNull() (similar to Doctrine's getOneOrNullResult() query function) that basically wraps retrieve() and catches a NotFoundException (and only that exception) and returns null instead of the entity.

*
* @param string $class_name
* @param int $id
* @return object\null
Copy link
Member

Choose a reason for hiding this comment

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

object|null

nedimdzendzo added a commit that referenced this pull request Feb 16, 2015
retrieve entities only if exist and DO NOT throw error if not found
@nedimdzendzo nedimdzendzo merged commit d45e95d into master Feb 16, 2015
@jordonsc jordonsc deleted the bugfix/retrieve-entity-only-if-exists branch September 3, 2015 23:15
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.

2 participants