diff --git a/src/FilterPluginManager.php b/src/FilterPluginManager.php index d556bf72..481e0bdf 100644 --- a/src/FilterPluginManager.php +++ b/src/FilterPluginManager.php @@ -20,65 +20,74 @@ */ class FilterPluginManager extends AbstractPluginManager { + /** + * Default set of plugins factories + * + * @var array + */ + protected $factories = array( + 'wordseparatortoseparator' => 'Zend\Filter\Word\Service\SeparatorToSeparatorFactory', + ); + /** * Default set of filters * * @var array */ protected $invokableClasses = array( - 'alnum' => 'Zend\I18n\Filter\Alnum', - 'alpha' => 'Zend\I18n\Filter\Alpha', - 'basename' => 'Zend\Filter\BaseName', - 'boolean' => 'Zend\Filter\Boolean', - 'callback' => 'Zend\Filter\Callback', - 'compress' => 'Zend\Filter\Compress', - 'compressbz2' => 'Zend\Filter\Compress\Bz2', - 'compressgz' => 'Zend\Filter\Compress\Gz', - 'compresslzf' => 'Zend\Filter\Compress\Lzf', - 'compressrar' => 'Zend\Filter\Compress\Rar', - 'compresssnappy' => 'Zend\Filter\Compress\Snappy', - 'compresstar' => 'Zend\Filter\Compress\Tar', - 'compresszip' => 'Zend\Filter\Compress\Zip', - 'datetimeformatter' => 'Zend\Filter\DateTimeFormatter', - 'decompress' => 'Zend\Filter\Decompress', - 'decrypt' => 'Zend\Filter\Decrypt', - 'digits' => 'Zend\Filter\Digits', - 'dir' => 'Zend\Filter\Dir', - 'encrypt' => 'Zend\Filter\Encrypt', - 'encryptblockcipher' => 'Zend\Filter\Encrypt\BlockCipher', - 'encryptopenssl' => 'Zend\Filter\Encrypt\Openssl', - 'filedecrypt' => 'Zend\Filter\File\Decrypt', - 'fileencrypt' => 'Zend\Filter\File\Encrypt', - 'filelowercase' => 'Zend\Filter\File\LowerCase', - 'filerename' => 'Zend\Filter\File\Rename', - 'filerenameupload' => 'Zend\Filter\File\RenameUpload', - 'fileuppercase' => 'Zend\Filter\File\UpperCase', - 'htmlentities' => 'Zend\Filter\HtmlEntities', - 'inflector' => 'Zend\Filter\Inflector', - 'int' => 'Zend\Filter\Int', - 'null' => 'Zend\Filter\Null', - 'numberformat' => 'Zend\I18n\Filter\NumberFormat', - 'numberparse' => 'Zend\I18n\Filter\NumberParse', - 'pregreplace' => 'Zend\Filter\PregReplace', - 'realpath' => 'Zend\Filter\RealPath', - 'stringtolower' => 'Zend\Filter\StringToLower', - 'stringtoupper' => 'Zend\Filter\StringToUpper', - 'stringtrim' => 'Zend\Filter\StringTrim', - 'stripnewlines' => 'Zend\Filter\StripNewlines', - 'striptags' => 'Zend\Filter\StripTags', - 'urinormalize' => 'Zend\Filter\UriNormalize', - 'wordcamelcasetodash' => 'Zend\Filter\Word\CamelCaseToDash', - 'wordcamelcasetoseparator' => 'Zend\Filter\Word\CamelCaseToSeparator', - 'wordcamelcasetounderscore' => 'Zend\Filter\Word\CamelCaseToUnderscore', - 'worddashtocamelcase' => 'Zend\Filter\Word\DashToCamelCase', - 'worddashtoseparator' => 'Zend\Filter\Word\DashToSeparator', - 'worddashtounderscore' => 'Zend\Filter\Word\DashToUnderscore', - 'wordseparatortocamelcase' => 'Zend\Filter\Word\SeparatorToCamelCase', - 'wordseparatortodash' => 'Zend\Filter\Word\SeparatorToDash', - 'wordseparatortoseparator' => 'Zend\Filter\Word\SeparatorToSeparator', - 'wordunderscoretocamelcase' => 'Zend\Filter\Word\UnderscoreToCamelCase', - 'wordunderscoretodash' => 'Zend\Filter\Word\UnderscoreToDash', - 'wordunderscoretoseparator' => 'Zend\Filter\Word\UnderscoreToSeparator', + 'alnum' => 'Zend\I18n\Filter\Alnum', + 'alpha' => 'Zend\I18n\Filter\Alpha', + 'basename' => 'Zend\Filter\BaseName', + 'boolean' => 'Zend\Filter\Boolean', + 'callback' => 'Zend\Filter\Callback', + 'compress' => 'Zend\Filter\Compress', + 'compressbz2' => 'Zend\Filter\Compress\Bz2', + 'compressgz' => 'Zend\Filter\Compress\Gz', + 'compresslzf' => 'Zend\Filter\Compress\Lzf', + 'compressrar' => 'Zend\Filter\Compress\Rar', + 'compresssnappy' => 'Zend\Filter\Compress\Snappy', + 'compresstar' => 'Zend\Filter\Compress\Tar', + 'compresszip' => 'Zend\Filter\Compress\Zip', + 'datetimeformatter' => 'Zend\Filter\DateTimeFormatter', + 'decompress' => 'Zend\Filter\Decompress', + 'decrypt' => 'Zend\Filter\Decrypt', + 'digits' => 'Zend\Filter\Digits', + 'dir' => 'Zend\Filter\Dir', + 'encrypt' => 'Zend\Filter\Encrypt', + 'encryptblockcipher' => 'Zend\Filter\Encrypt\BlockCipher', + 'encryptopenssl' => 'Zend\Filter\Encrypt\Openssl', + 'filedecrypt' => 'Zend\Filter\File\Decrypt', + 'fileencrypt' => 'Zend\Filter\File\Encrypt', + 'filelowercase' => 'Zend\Filter\File\LowerCase', + 'filerename' => 'Zend\Filter\File\Rename', + 'filerenameupload' => 'Zend\Filter\File\RenameUpload', + 'fileuppercase' => 'Zend\Filter\File\UpperCase', + 'htmlentities' => 'Zend\Filter\HtmlEntities', + 'inflector' => 'Zend\Filter\Inflector', + 'int' => 'Zend\Filter\Int', + 'null' => 'Zend\Filter\Null', + 'numberformat' => 'Zend\I18n\Filter\NumberFormat', + 'numberparse' => 'Zend\I18n\Filter\NumberParse', + 'pregreplace' => 'Zend\Filter\PregReplace', + 'realpath' => 'Zend\Filter\RealPath', + 'stringtolower' => 'Zend\Filter\StringToLower', + 'stringtoupper' => 'Zend\Filter\StringToUpper', + 'stringtrim' => 'Zend\Filter\StringTrim', + 'stripnewlines' => 'Zend\Filter\StripNewlines', + 'striptags' => 'Zend\Filter\StripTags', + 'urinormalize' => 'Zend\Filter\UriNormalize', + 'wordcamelcasetodash' => 'Zend\Filter\Word\CamelCaseToDash', + 'wordcamelcasetoseparator' => 'Zend\Filter\Word\CamelCaseToSeparator', + 'wordcamelcasetounderscore' => 'Zend\Filter\Word\CamelCaseToUnderscore', + 'worddashtocamelcase' => 'Zend\Filter\Word\DashToCamelCase', + 'worddashtoseparator' => 'Zend\Filter\Word\DashToSeparator', + 'worddashtounderscore' => 'Zend\Filter\Word\DashToUnderscore', + 'wordseparatortocamelcase' => 'Zend\Filter\Word\SeparatorToCamelCase', + 'wordseparatortodash' => 'Zend\Filter\Word\SeparatorToDash', + 'wordunderscoretocamelcase' => 'Zend\Filter\Word\UnderscoreToCamelCase', + 'wordunderscoretostudlycase' => 'Zend\Filter\Word\UnderscoreToStudlyCase', + 'wordunderscoretodash' => 'Zend\Filter\Word\UnderscoreToDash', + 'wordunderscoretoseparator' => 'Zend\Filter\Word\UnderscoreToSeparator', ); /** diff --git a/src/Word/Service/SeparatorToSeparatorFactory.php b/src/Word/Service/SeparatorToSeparatorFactory.php new file mode 100644 index 00000000..148ac3b0 --- /dev/null +++ b/src/Word/Service/SeparatorToSeparatorFactory.php @@ -0,0 +1,53 @@ +creationOptions = $creationOptions; + } + + /** + * Get creation options + * + * @return array + */ + public function getCreationOptions() + { + return $this->creationOptions; + } + + /** + * {@inheritDoc} + * + * @return SeparatorToSeparator + * @throws ServiceNotCreatedException if Controllermanager service is not found in application service locator + */ + public function createService(ServiceLocatorInterface $plugins) + { + return new SeparatorToSeparator( + isset($this->creationOptions['search_separator']) ? $this->creationOptions['search_separator'] : ' ', + isset($this->creationOptions['replacement_separator']) ? $this->creationOptions['replacement_separator'] : '-' + ); + } +} diff --git a/test/FilterPluginManagerTest.php b/test/FilterPluginManagerTest.php index e24ffdf6..88e873b5 100644 --- a/test/FilterPluginManagerTest.php +++ b/test/FilterPluginManagerTest.php @@ -39,4 +39,44 @@ public function testLoadingInvalidFilterRaisesException() $this->setExpectedException('Zend\Filter\Exception\RuntimeException'); $this->filters->get('test'); } + + /** + * @group 7169 + */ + public function testFilterSuccessfullyConstructed() + { + $search_separator = ';'; + $replacement_separator = '|'; + $options = array( + 'search_separator' => $search_separator, + 'replacement_separator' => $replacement_separator, + ); + $filter = $this->filters->get('wordseparatortoseparator', $options); + $this->assertInstanceOf('Zend\Filter\Word\SeparatorToSeparator', $filter); + $this->assertEquals(';', $filter->getSearchSeparator()); + $this->assertEquals('|', $filter->getReplacementSeparator()); + } + + /** + * @group 7169 + */ + public function testFiltersConstructedAreDifferent() + { + $filterOne = $this->filters->get( + 'wordseparatortoseparator', + array( + 'search_separator' => ';', + 'replacement_separator' => '|', + ) + ); + $filterTwo = $this->filters->get( + 'wordseparatortoseparator', + array( + 'search_separator' => '.', + 'replacement_separator' => ',', + ) + ); + + $this->assertNotEquals($filterOne, $filterTwo); + } }