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 ObjectManager::isUninitializedObject() #334

Merged
merged 1 commit into from
Jul 12, 2023

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Jul 10, 2023

For 3.3

Adding ObjectManager::isUninitializedObject() will allow userland to decouple from the Proxy interface:

before:

if ($entity instanceof Proxy && !$entity->__isInitialized()) {
    $entity->__load();
}

after:

if ($em->isUninitializedObject($entity)) {
    $em->initializeObject($entity);
}

Also, I removed Proxy::__setInitialized() as I figured out it shouldn't be exposed as public API and it should remain an internal concern.

Copy link
Member

@stof stof left a comment

Choose a reason for hiding this comment

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

I don't think any API of doctrine/persistence uses the term Entity right now, which is a term used only by the ORM project but not by the ODM.

@@ -9,6 +9,8 @@

/**
* Contract for a Doctrine persistence layer ObjectManager class to implement.
*
* @method bool isUninitializedEntity(mixed $value)
Copy link
Member

Choose a reason for hiding this comment

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

should this be mixed or object ?

Copy link
Member Author

@nicolas-grekas nicolas-grekas Jul 10, 2023

Choose a reason for hiding this comment

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

it's mixed because this is commonly used against any values, eg in the UoW

Copy link
Member

Choose a reason for hiding this comment

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

The object manager manages objects only, so object $object would indeed make sense here imho. It would also be consistent with all other methods on this interface.

@nicolas-grekas nicolas-grekas changed the title Add ObjectManager::isUninitializedEntity() Add ObjectManager::isUninitializedObject() Jul 10, 2023
@nicolas-grekas
Copy link
Member Author

OK, renamed to isUninitializedObject then.

greg0ire
greg0ire previously approved these changes Jul 11, 2023
SenseException
SenseException previously approved these changes Jul 11, 2023
@greg0ire
Copy link
Member

For 3.3

Wrong branch then?

@nicolas-grekas nicolas-grekas changed the base branch from 3.2.x to 3.3.x July 12, 2023 06:36
@nicolas-grekas nicolas-grekas dismissed stale reviews from SenseException and greg0ire July 12, 2023 06:36

The base branch was changed.

@nicolas-grekas
Copy link
Member Author

I just created branch 3.3.x and changed the target of this PR. But I don't have permission to update the default branch on github.

@greg0ire
Copy link
Member

Having the stable branch as the default branch is the policy for this repository AFAIK, having the next minor as default branch is a policy for the ODM, and maybe a few more, but not this one, so you did well.

@greg0ire greg0ire merged commit e2546e1 into doctrine:3.3.x Jul 12, 2023
@greg0ire greg0ire added this to the 3.3.0 milestone Jul 12, 2023
@greg0ire greg0ire added the Enhancement New feature or request label Jul 12, 2023
@greg0ire
Copy link
Member

Thanks @nicolas-grekas !

dbu added a commit to doctrine/phpcr-odm that referenced this pull request May 5, 2024
dbu added a commit to doctrine/phpcr-odm that referenced this pull request May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants