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 an ObjectConstructor which can load an object from the database #141

Closed
schmittjoh opened this issue Jun 29, 2012 · 2 comments · Fixed by #185
Closed

Add an ObjectConstructor which can load an object from the database #141

schmittjoh opened this issue Jun 29, 2012 · 2 comments · Fixed by #185

Comments

@schmittjoh
Copy link
Owner

If someone wants to modify an object partially, he currently needs to write a class which implements ObjectConstructorInterface. Maybe we can provide an implementation by default.

class DoctrineObjectConstructor extends UnserializeObjectConstructor
{
    private $em;

    public function construct($metadata, $class, $data, $visitor) 
    {
        if ($this->em->isTransient($class)) {
            return parent::construct(/* ... */);
        }

        // do some query and return the object
    }
}

see #111

@robocoder
Copy link
Contributor

Wouldn't the interface have to change so that the entity manager can be set before unserializing in the constructor?

@schmittjoh
Copy link
Owner Author

I think you are confusing construct with __construct.

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 a pull request may close this issue.

2 participants