Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Allow to change option creations for plugin manager #4104

Closed
wants to merge 6 commits into from

Conversation

bakura10
Copy link
Contributor

Currently, the plugin manager offer a way to give creation options. When using factories, those options are injected into the factory constructor. However, as the factory is instantiated only once, if the user get a new, non-shared instance to the plugin manager with new options, those new options are not updated because the factory still uses the ones that were given to him when he was created.

This is a bit hacky as the service manager was not really thought for creation options, but it works. Now, it will check the existence of setCreationOptions on any factory and call it with the options given.

$this->creationOptions = $creationOptions;
}

public function setCreationOptions(array $creationOptions)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would put the method "setCreateOptions" and "getCreateOptions" in a "FactoryWithCreateOptionsInterface". (Perhabs you'll find a better name for it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, this is a good idea too, I've thought about it. But I could not find a nice name so I went with the method_exists ;-).

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @prolic -- the new methods need a corresponding interface. May I suggest MutableCreationOptionsInterface? You can test against that, and/or do duck typing -- just good to have the interface there in part as documentation.

* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license.
Copy link
Member

Choose a reason for hiding this comment

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

Umm... why is this docblock here? This isn't apropos to ZF2! :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops... My PHPStorm automatiocallly ad docblock...

@ghost ghost assigned weierophinney Mar 28, 2013
weierophinney added a commit that referenced this pull request Mar 28, 2013
Allow to change option creations for plugin manager
weierophinney added a commit that referenced this pull request Mar 28, 2013
Allow to change option creations for plugin manager
weierophinney added a commit that referenced this pull request Mar 28, 2013
@weierophinney
Copy link
Member

Merged last week... evidently did not autoclose!

weierophinney added a commit to zendframework/zend-servicemanager that referenced this pull request May 15, 2015
…ion-factory

Allow to change option creations for plugin manager
weierophinney added a commit to zendframework/zend-servicemanager that referenced this pull request May 15, 2015
…ion-factory

Allow to change option creations for plugin manager
weierophinney added a commit to zendframework/zend-servicemanager that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants