Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Lazy loading not working for parameters #26

Closed
alganet opened this Issue · 3 comments

2 participants

@alganet
Owner

When an instantiator is passed to another instance by parameter (and possibly by other ways) it isn't being instantiated. This was introduced after 0.3.1.

@nickl- nickl- referenced this issue from a commit
@nickl- nickl- Test for fix for #26 lazy load instance parameters.
Solution for #26 allow manipulating instances as paramoters.
ea9f4c6
@nickl-
Owner

I think this is the fix you are looking for:

Given config

my_string = 'Hey you!'

[hello Respect\Config\MyLazyLoadedHelloWorld]
string = [my_string]

[consumer Respect\Config\MyLazyLoadedHelloWorldConsumer]
hello = [hello]

The following lazy load manipulation can be performed. (referred to internally as the overriding of configuration by container state)

        $expected  = 'Hello World!';
        $container = new Container($config);
        $container->my_string = $expected;
        $this->assertEquals($expected, (string) $container->hello);
        $container = new Container($config);
        $container->{"hello Respect\\Config\\MyLazyLoadedHelloWorld"} = array('string' => $expected);
        $this->assertEquals($expected, (string) $container->hello);
        $container = new Container($config);
        $container->hello = new MyLazyLoadedHelloWorld($expected);
        $this->assertEquals($expected, (string) $container->hello);

I think these are useful none the less but @alganet please confirm if it also addresses this issue.

@alganet
Owner

Nice! It addresses =)

@nickl-
Owner

Closed on confirmed success

@nickl- nickl- closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.