zendframework/zf2 — pull request #5254 by weierophinney (2013-10-30 21:28:47+00:00)
Title: Zend\Log\Writer\Db via config throws exception

I use this config to create a logger:

```
'log' => array(
'Application\Log' => array(
'writers' => array(
array(
'name' => 'db',
'priority' => 1,
'options' => array(
'separator' => '_',
'column' => array(),
'table' => 'applicationlog',
'db' => 'Zend\Db\Adapter\Adapter',
),
),
),
#'exceptionhandler' => true,
#'errorhandler' => true,
),
),
```
With this config I can get the logger via the service manager:
```php
$serviceManager->get('Application\Log');
```

This results in the following exception:
> Zend\Log\Exception\InvalidArgumentException: You must pass a valid Zend\Db\Adapter\Adapter in [...]\vendor\zendframework\zendframework\library\Zend\Log\Writer\Db.php on line 74

`Zend\Log\Writer\Db` expects an instance of `Zend\Db\Adapter\Adapter` for the option key `db`.

Suggested fixes:
- If `db` is a string, use the service manager to get the class by the name provided in the `db` option key.
- If `db` is a closure, get the result of the closure.

When the string possibility and the closure possibility is checked and processed there can be checked if this results in a valid instance of `Zend\Db\Adapter\Adapter`.