ralphschindler/Zend_DI-Examples — Issue #1: Static factory method use case
Author: theUniC
Created: 2011-12-29 08:32:40+00:00
State: open

Hi Ralph,

Could be possible to add a static factory method use case as an example? I'm in the case I have a dependency of a `Zend\Cache\Storage\Adapter\AbstractAdapter` that gets generated via `Zend\Cache\StorageFactory`, but I'm not able to find the way to get an instance of the AbstractAdapter and fullfil the dependency. Googling a bit I could get this snippet from some example seen in a gist

```php
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(
'class_with_dependency' => 'Class\With\Dependency',
'zend_cache_storage_adapter_apc' => 'Zend\Cache\Storage\Adapter\AbstractAdapter'
),

'class_with_dependency' => array(
'injections' => array(
'cache' => 'zend_cache_storage_adapter_apc'
)
),
'zend_cache_storage_adapter_apc' => array(
'parameters' => array(
'cfg' => array(
'adapter' => array(
'name' => 'apc',
'options' => array(
'ttl' => 123,
)
),
'plugins' => array('Serializer')
)
)
)
),
),
);
```
Thanks in advance!
Christian.