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

EntityManager::__cosntruct() as public method #1293

Closed
wants to merge 4 commits into from

Conversation

mcspronko
Copy link

Updated EntityManager::__construct() method to public visibility:

  • moved create() method to EntityManagerFactory class
  • added new Configuration class methods for UnitOfWork and ProxyFactory classes
  • updated documentation
  • updated unit and functional tests

 - moved create() method to EntityManagerFactory class
 - added new Configuration class methods for UnitOfWork and ProxyFactory classes
 - updated documentation
 - updated unit and functional tests
@doctrinebot
Copy link

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DDC-3550

We use Jira to track the state of pull requests and the versions they got
included in.

* @throws \InvalidArgumentException
* @throws ORMException
*/
public static function create($conn, Configuration $config, EventManager $eventManager = null)
Copy link
Contributor

Choose a reason for hiding this comment

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

removing this method would an unnecesary BC Break

Copy link

Choose a reason for hiding this comment

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

agree

Copy link
Author

Choose a reason for hiding this comment

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

As for now EntityManager has a lot of responsibilities including creation of its own instance. Separate class should prepare and instantiate EntityManager. I agree that this is backward incompatible change. The strategy might be changed based on release policy. In case 2.5.* allows to introduce this change, we are in a good shape. Alternatively, this method might marked as @deprecated since 2.5 and proxy behavior to the EntityManagerFactory
Like this:

    /**
     * @deprecated since 2.5
     */
    public static function create($conn, Configuration $config, EventManager $eventManager = null)
    {
        return new EntityManagerFactory($conn, $config, $eventManager);
    }

Thanks

Copy link
Member

Choose a reason for hiding this comment

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

@mcspronko BC breaks are forbidden in minor versions. Semver means that any BC break in the public API requires bumping the major version

Copy link
Author

Choose a reason for hiding this comment

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

@stof so option with deprecated create() method should be ok for minor change.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can mark it deprecated, but you cannot change the behaviour.

Copy link
Author

Choose a reason for hiding this comment

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

Agree, my mistake it should be like this

    /**
     * @deprecated since 2.5
     */
    public static function create($conn, Configuration $config, EventManager $eventManager = null)
    {
        return EntityManagerFactory::create($conn, $config, $eventManager);
    }

where create() behavior is the same.
Thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

why do you have the new there?

Copy link
Author

Choose a reason for hiding this comment

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

TYPO :)

@Majkl578
Copy link
Contributor

EntityManager::__construct() is not public by design and EntityManager::create() is the only exposed and proper way to instantiate new instance. Also EntityManager will become final in Doctrine 3.0.
Additionally configuring UnitOfWork class name shouldn't be possible, it is not intended to be extended or replaced as it contains pretty sensitive code.

Valid extension point to enhance EntityManager is through decorator pattern using EntityManagerInterface, not inheritance.
If you still think this is needed and want to update this PR (if so, please on top of develop branch), let me know and I will reopen. I think extracting factory to separate class could be eventually considered, but not configurable UnitOfWork. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants