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

Allow skipping properties in LazyLoadingGhost for partial initialization #212

Closed
Ocramius opened this issue Dec 18, 2014 · 1 comment
Closed
Assignees
Milestone

Comments

@Ocramius
Copy link
Owner

In order to use lazy loading ghost objects in different contexts, we may need to allow partial initialization as well.

One way to do that is to generate different proxy classes for different sets of properties being requested to be skipped from following lazy-loading semantics.

A possible API implementation may look like following:

class LazyLoadingGhostFactory extends AbstractLazyFactory
{
    public function createProxy(
        $className,
        \Closure $initializer,
        array $options = []
    ) {
        /* ... */
    }
}

A possible usage may be like following:

// no properties skipped
$proxy = $factory->createProxy('Foo', function () { /* ... */ });
// skip privateProperty, protectedProperty and publicProperty
$proxy = $factory->createProxy(
    'Foo',
    function () { /* ... */ },
    ['skippedProperties' => ["\0Foo\0privateProperty", "\0*\0protectedProperty", "publicProperty"]]
);

In order to avoid class inheritance collisions, values of 'skippedProperties' are PHP's internal logical property names (used for array serialization).

Ping @malukenho want to give this a shot?

@Ocramius
Copy link
Owner Author

Ocramius commented Jan 8, 2015

Handled in #221

@Ocramius Ocramius closed this as completed Jan 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant