-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Allow to change option creations for plugin manager #4104
Conversation
$this->creationOptions = $creationOptions; | ||
} | ||
|
||
public function setCreationOptions(array $creationOptions) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 ;-).
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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! :)
There was a problem hiding this comment.
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...
Allow to change option creations for plugin manager
Allow to change option creations for plugin manager
Merged last week... evidently did not autoclose! |
…ion-factory Allow to change option creations for plugin manager
…ion-factory Allow to change option creations for plugin manager
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.