Created
August 28, 2013 17:09
-
-
Save Bittarman/6368543 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
/** | |
* @copyright Lupimedia ltd 2013 | |
*/ | |
namespace Contentled\Filter; | |
use Zend\Filter\Exception; | |
use Zend\Filter\FilterInterface; | |
class FormatActivationKey implements FilterInterface | |
{ | |
/** | |
* Returns the result of filtering $value | |
* | |
* @param mixed $value | |
* @throws Exception\RuntimeException If filtering $value is impossible | |
* @return mixed | |
*/ | |
public function filter($value) | |
{ | |
$value = str_replace('-', '', $value); | |
return trim(chunk_split($value, 4, '-'), '-'); | |
} | |
} |
This file contains 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
<?php | |
/** | |
* @copyright Lupimedia ltd 2013 | |
*/ | |
namespace Contentled\Filter; | |
use Zend\ServiceManager\FactoryInterface; | |
use Zend\ServiceManager\ServiceLocatorInterface; | |
class FormatActivationKeyFactory implements FactoryInterface | |
{ | |
/** | |
* Create service | |
* | |
* @param ServiceLocatorInterface $serviceLocator | |
* @return mixed | |
*/ | |
public function createService(ServiceLocatorInterface $serviceLocator) | |
{ | |
return new FormatActivationKey(); // you could inject dependencies here | |
} | |
} |
This file contains 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
<?php | |
/** | |
* @copyright Lupimedia ltd 2013 | |
*/ | |
namespace Contentled; | |
class Module | |
{ | |
/** | |
* @return array | |
*/ | |
public function getServiceConfig() | |
{ | |
return [ | |
'factories' => [ | |
'FormatActivationKey' => 'Contentled\Filter\FormatActivationKeyFactory', | |
'Form\ConfirmRegistration' => function($sm) { | |
$form = new Form\ConfirmRegistration('confirm-registration'); | |
$plugins = $sm->get('FilterManager'); | |
$chain = new FilterChain(); | |
$chain->setPluginManager($plugins); | |
$form->getFormFactory()->getInputFilterFactory()->setDefaultFilterChain($chain); | |
return $form; | |
}, | |
] | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment