Skip to content

Instantly share code, notes, and snippets.

@stefanotorresi
Created July 9, 2013 15:29
Show Gist options
  • Save stefanotorresi/5958307 to your computer and use it in GitHub Desktop.
Save stefanotorresi/5958307 to your computer and use it in GitHub Desktop.
custom input filter services
<?php
use Zend\Filter\FilterChain;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class FormFactory implements FactoryInterface
{
public function createService(ServiceLocatorInterface $serviceLocator)
{
$form = new Form();
// injecting the filtermanager is needed to use custom filter services
$chain = new FilterChain();
$chain->setPluginManager($serviceLocator->get('FilterManager'));
$form->getFormFactory()->getInputFilterFactory()->setDefaultFilterChain($chain);
return $form;
}
}
<?php
return array(
'type' => 'myfilter'
);
<?php
return array(
'filters' => array(
'invokables' => array(
'myfilter' => 'My\Fancy\Filter',
),
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment