akrabat / rka-slim-zfsm-container

Integration of Zend\ServiceManager into Slim 3
BSD 3-Clause "New" or "Revised" License
9 stars 3 forks source link

Override slim default handlers #3

Closed garethellis36 closed 9 years ago

garethellis36 commented 9 years ago

This PR adds the option to pass in alternatives to the default services, e.g. an error handler. Alternatives are passed as second constructor argument as an associative array.

garethellis36 commented 9 years ago

So as fun an exercise as this was, I realized that it doesn't actually do what I hoped it would because my custom error class has dependency on Logger and Twig. Therefore this $this->setInvokableClass('errorHandler', $defaultHandlers["errorHandler"]); just results in a fatal error when I actually encounter an error in my app because it's not passing in the dependencies. Any suggestions? :-)

garethellis36 commented 9 years ago

I just discovered ServiceManager::setAllowOverride() which simultaneously solved my problem and ruined my evening. Sorry to bother you!! :)

akrabat commented 9 years ago

:)