theUniC wrote
>
> Hi all,
>
> I would like to know what would be the best way to configure an instance
> of
> an adapter class generated through a factory method from another class. In
> my concrete example, I have a component which has dependency on *
> Zend\Cache\Storage\Adapter\AbstractAdapter* whose instances get generated
> through the class *Zend\Cache\StorageFactory*. So I would like to know
> what
> would be the proper way to specify the "generation" of this class in the
> "module.config.php" file. Currently, I have this config
>
> <?php
>
> return array(
>
> 'di' => array(
>
> 'definition' => array(
>
> 'class' => array(
>
> 'Zend\Cache\StorageFactory' => array(
>
> 'methods' => array(
>
> 'factory' => array(
>
> 'cfg' => array(
>
> 'type' => false,
>
> 'required' => true
>
> )
>
> )
>
> )
>
> ),
>
> 'Zend\Cache\Storage\Adapter\AbstractAdapter' => array(
>
> 'instantiator' => array(
>
> 'Zend\Cache\StorageFactory',
>
> 'factory'
>
> )
>
> )
>
> )
>
> ),
>
> 'instance' => array(
>
> 'alias' => array(
>
> 'my_component' => 'My\Component',
>
> 'zend_cache_storage_adapter_apc' =>
> 'Zend\Cache\Storage\Adapter\AbstractAdapter'
>
> ),
>
> 'my_component' => array(
>
> 'injections' => array(
>
> 'cache' => 'zend_cache_storage_adapter_apc'
>
> )
>
> ),
>
> 'zend_cache_storage_adapter_apc' => array(
>
> 'parameters' => array(
>
> 'adapter' => array(
>
> 'name' => 'apc',
>
> 'options' => array(
>
> 'ttl' => 123,
>
> )
>
> ),
>
> 'plugins' => array('Serializer')
>
> )
>
> )
>
> )
>
> )
>
> );
> When the code gets executed, a
> *"Zend\Di\Exception\MissingPropertyException"
> * is thrown telling "Missing instance/object for parameter cfg for
> Zend\Cache\StorageFactory::factory".
>
> I have googled a lot, but no way to find a good example of this kind of
> situation. If someone could help me, it would be so appreciated!!
>
> Thanks in advance!
> Christian.
>
theUniC,
Did you find a solution to this?
I'm also getting the same error even though I pass the cfg parameter;
'di' => array(
'instance' => array(
'alias' => array(
'cache' => 'Zend\Cache\StorageFactory',
),
'cache' => array(
'injections' => array(
'factory' => array(
*'cfg'* => array(
'adapter' => array(
'name' => 'Filesystem',
'options' => array(
'dirLevel' => 2,
'cacheDir' =>
__DIR__ . '/../../data/cache',
),
),
'plugins' => array(
'Serializer'
),
),
),
),
),
),
)
*PHP Warning: Missing argument 1 for Zend\Cache\StorageFactory::factory()
in /***/Zend/Cache/StorageFactory.php on line 59*
Thanks!
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/ZF2-Factory-method-and-Zend-Di-tp4257197p4552674.html
Sent from the Zend Framework mailing list archive at Nabble.com.
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]