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.