Last active
August 29, 2015 14:05
-
-
Save manuakasam/21554b85779b2ae2ba4f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'filters' => [ 'invokables' => [ 'fooFilter' => 'My\Namespace\FooFilter']] | |
| class FooFilter implements FilterInterface | |
| { | |
| public function filter($str) { | |
| $str = magic_happens($str); | |
| return $str; | |
| } | |
| } | |
| class ControllerFactory implements FactoryInterface { | |
| public function createService(ServiceLocatorInterface $sl) { | |
| $realSl = $sl->getServiceLocator(); | |
| $filterManager = $realSl->get('FilterManager'); | |
| return new Controller( | |
| $filterManager->get('fooFilter') | |
| ); | |
| } | |
| } | |
| class Controller { | |
| public functino __construct($filter) { | |
| $this->filter = $filter; | |
| } | |
| public function someAction() | |
| { | |
| return [ | |
| 'filtered_string' => $this->filter->filter('LetTheMagicHappen') | |
| ]; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment