AbstractPluginManager & options - creationOptions will not work as newInstanceArgs ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

AbstractPluginManager & options - creationOptions will not work as newInstanceArgs ?

sasezaki
Hi, all.

With latest zf2, I got unexpected result.

code:
<?php
$logger = new Zend\Log\Logger;
$logger->addWriter('stream', 1, ['php://memory']);

result:
PHP Fatal error:  Uncaught exception
'Zend\Log\Exception\RuntimeException' with message '"" cannot be
opened with mode "a"' in
/home/kazusuke/dev/sasezaki_zf2/library/Zend/Log/Writer/Stream.php:84
Stack trace:
#0 /home/kazusuke/dev/sasezaki_zf2/library/Zend/ServiceManager/AbstractPluginManager.php(187):
Zend\Log\Writer\Stream->__construct(Array)
#1 /home/kazusuke/dev/sasezaki_zf2/library/Zend/ServiceManager/ServiceManager.php(450):
Zend\ServiceManager\AbstractPluginManager->createFromInvokable('stream',
'stream')
#2 /home/kazusuke/dev/sasezaki_zf2/library/Zend/ServiceManager/ServiceManager.php(403):
Zend\ServiceManager\ServiceManager->create(Array)
#3 /home/kazusuke/dev/sasezaki_zf2/library/Zend/ServiceManager/AbstractPluginManager.php(109):
Zend\ServiceManager\ServiceManager->get('stream', true)
#4 /home/kazusuke/dev/sasezaki_zf2/library/Zend/Log/Logger.php(154):
Zend\ServiceManager\AbstractPluginManager->get('stream', Array)
#5 /home/kazusuke/dev/sasezaki_zf2/library/Zend/Log/Logger.php(168):
Zend\Log\Logger->writerPlugin('s in
/home/kazusuke/dev/sasezaki_zf2/library/Zend/Log/Writer/Stream.php on
line 84



currently,
AbstractPluginManager create instance with any array.
#0 /home/kazusuke/dev/sasezaki_zf2/library/Zend/ServiceManager/AbstractPluginManager.php(187):
Zend\Log\Writer\Stream->__construct(Array)
https://github.com/zendframework/zf2/blob/bc94a43a6f6d9bb3f762bd2a76d84be9571c2328/library/Zend/ServiceManager/AbstractPluginManager.php#L187

but previous was support PluginBroker checking isAssocArray or isList
automatically.
https://github.com/zendframework/zf2/blob/release-2.0.0beta4/library/Zend/Loader/PluginBroker.php#L249

Is removed creating instance from options as newInstanceArgs?
Do I miss information about latest plugin architecture?

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: AbstractPluginManager & options - creationOptions will not work as newInstanceArgs ?

weierophinney
Administrator
-- sasezaki <[hidden email]> wrote
(on Friday, 03 August 2012, 06:11 PM +0900):
> With latest zf2, I got unexpected result.
>
> code:
> <?php
> $logger = new Zend\Log\Logger;
> $logger->addWriter('stream', 1, ['php://memory']);

Try this instead:

    $logger->addWriter('stream', 1, [
        'stream' => 'php://memory',
        'mode'   => 'a',
    ]);

<snip>

> Is removed creating instance from options as newInstanceArgs?
> Do I miss information about latest plugin architecture?

Correct -- newInstanceArgs is no longer used; instead the array is
passed as an argument to the constructor. (This was changed to make it
more consistent with other components that have plugins in the
framework, and done prior to rc1.)

--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: AbstractPluginManager & options - creationOptions will not work as newInstanceArgs ?

sasezaki
Hi.

2012/8/3 Matthew Weier O'Phinney <[hidden email]>:
> Try this instead:
>
>     $logger->addWriter('stream', 1, [
>         'stream' => 'php://memory',
>         'mode'   => 'a',
>     ]);

Thanks about example.

> Correct -- newInstanceArgs is no longer used; instead the array is
> passed as an argument to the constructor. (This was changed to make it
> more consistent with other components that have plugins in the
> framework, and done prior to rc1.)
I accept this change. (Sorry, I had not catch up it.)

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Loading...