From 360465c8c8f7413cbf736b8f77f571eb0c6ec612 Mon Sep 17 00:00:00 2001 From: Patrick Guiran Date: Sun, 25 Jan 2015 19:13:01 +0100 Subject: [PATCH 01/10] register plugin wordseparatortoseparator factory --- src/FilterPluginManager.php | 116 ++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 53 deletions(-) diff --git a/src/FilterPluginManager.php b/src/FilterPluginManager.php index d556bf72..47850b73 100644 --- a/src/FilterPluginManager.php +++ b/src/FilterPluginManager.php @@ -20,65 +20,75 @@ */ 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', + 'wordseparatortoseparator' => 'Zend\Filter\Word\SeparatorToSeparator', + 'wordunderscoretocamelcase' => 'Zend\Filter\Word\UnderscoreToCamelCase', + 'wordunderscoretostudlycase' => 'Zend\Filter\Word\UnderscoreToStudlyCase', + 'wordunderscoretodash' => 'Zend\Filter\Word\UnderscoreToDash', + 'wordunderscoretoseparator' => 'Zend\Filter\Word\UnderscoreToSeparator', ); /** From 32620d7e8c24f849b3302feaa6bb571e8bc9d72e Mon Sep 17 00:00:00 2001 From: Patrick Guiran Date: Sun, 25 Jan 2015 19:13:16 +0100 Subject: [PATCH 02/10] add tests for wordseparatortoseparator building --- test/FilterPluginManagerTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/FilterPluginManagerTest.php b/test/FilterPluginManagerTest.php index e24ffdf6..d3de95e6 100644 --- a/test/FilterPluginManagerTest.php +++ b/test/FilterPluginManagerTest.php @@ -39,4 +39,18 @@ public function testLoadingInvalidFilterRaisesException() $this->setExpectedException('Zend\Filter\Exception\RuntimeException'); $this->filters->get('test'); } + + 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()); + } } From e25cef174b1be2ba468d8903d715aaa5ec2f48f4 Mon Sep 17 00:00:00 2001 From: Patrick Guiran Date: Fri, 30 Jan 2015 15:30:12 +0100 Subject: [PATCH 03/10] PSR coding style + comment --- src/Word/Service/SeparatorToSeparatorFactory.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Word/Service/SeparatorToSeparatorFactory.php b/src/Word/Service/SeparatorToSeparatorFactory.php index 37e68913..f8897c18 100644 --- a/src/Word/Service/SeparatorToSeparatorFactory.php +++ b/src/Word/Service/SeparatorToSeparatorFactory.php @@ -9,6 +9,9 @@ class SeparatorToSeparatorFactory implements FactoryInterface { + /** + * @var array + */ protected $options; /** @@ -16,14 +19,15 @@ class SeparatorToSeparatorFactory implements FactoryInterface * * @param array $options */ - public function __construct($options = array()) { + public function __construct(array $options = array()) + { $this->options = $options; } /** * {@inheritDoc} * - * @return Forward + * @return SeparatorToSeparator * @throws ServiceNotCreatedException if Controllermanager service is not found in application service locator */ public function createService(ServiceLocatorInterface $plugins) From b034d69219676236e1bc4ec91a28649fe3af4497 Mon Sep 17 00:00:00 2001 From: Patrick Guiran Date: Fri, 30 Jan 2015 15:40:15 +0100 Subject: [PATCH 04/10] coding style --- src/Word/Service/SeparatorToSeparatorFactory.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Word/Service/SeparatorToSeparatorFactory.php b/src/Word/Service/SeparatorToSeparatorFactory.php index f8897c18..3d94f500 100644 --- a/src/Word/Service/SeparatorToSeparatorFactory.php +++ b/src/Word/Service/SeparatorToSeparatorFactory.php @@ -37,5 +37,4 @@ public function createService(ServiceLocatorInterface $plugins) isset($this->options['replacement_separator']) ? $this->options['replacement_separator'] : '-' ); } - -} \ No newline at end of file +} From 8187ab9dd1848f0de465b23fe4e81793a370bea5 Mon Sep 17 00:00:00 2001 From: Patrick Guiran Date: Sun, 1 Feb 2015 14:51:56 +0100 Subject: [PATCH 05/10] use MutableCreationOptionsTrait and MutableCreationOptionsInterface --- .../Service/SeparatorToSeparatorFactory.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Word/Service/SeparatorToSeparatorFactory.php b/src/Word/Service/SeparatorToSeparatorFactory.php index 3d94f500..65c89111 100644 --- a/src/Word/Service/SeparatorToSeparatorFactory.php +++ b/src/Word/Service/SeparatorToSeparatorFactory.php @@ -2,17 +2,17 @@ namespace Zend\Filter\Word\Service; -use Zend\ServiceManager\Exception\ServiceNotCreatedException; +use Zend\Filter\Word\SeparatorToSeparator; use Zend\ServiceManager\FactoryInterface; +use Zend\ServiceManager\MutableCreationOptionsInterface; +use Zend\ServiceManager\MutableCreationOptionsTrait; use Zend\ServiceManager\ServiceLocatorInterface; -use Zend\Filter\Word\SeparatorToSeparator; -class SeparatorToSeparatorFactory implements FactoryInterface +class SeparatorToSeparatorFactory implements + FactoryInterface, + MutableCreationOptionsInterface { - /** - * @var array - */ - protected $options; + use MutableCreationOptionsTrait; /** * Constructor. @@ -21,7 +21,7 @@ class SeparatorToSeparatorFactory implements FactoryInterface */ public function __construct(array $options = array()) { - $this->options = $options; + $this->setCreationOptions($options); } /** @@ -33,8 +33,8 @@ public function __construct(array $options = array()) public function createService(ServiceLocatorInterface $plugins) { return new SeparatorToSeparator( - isset($this->options['search_separator']) ? $this->options['search_separator'] : ' ', - isset($this->options['replacement_separator']) ? $this->options['replacement_separator'] : '-' + isset($this->creationOptions['search_separator']) ? $this->creationOptions['search_separator'] : ' ', + isset($this->creationOptions['replacement_separator']) ? $this->creationOptions['replacement_separator'] : '-' ); } } From 6d6a9a6e3df1aa132a8383cb0aa8eeef47a346e7 Mon Sep 17 00:00:00 2001 From: Patrick Guiran Date: Sun, 1 Feb 2015 14:52:22 +0100 Subject: [PATCH 06/10] add a test to check we can create different SeparatorToSeparator instance --- test/FilterPluginManagerTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/FilterPluginManagerTest.php b/test/FilterPluginManagerTest.php index d3de95e6..18f5af64 100644 --- a/test/FilterPluginManagerTest.php +++ b/test/FilterPluginManagerTest.php @@ -53,4 +53,24 @@ public function testFilterSuccessfullyConstructed() $this->assertEquals(';', $filter->getSearchSeparator()); $this->assertEquals('|', $filter->getReplacementSeparator()); } + + 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); + } } From 8c17cc2cfd9a42cc12c67ce93c0f98be5959dd86 Mon Sep 17 00:00:00 2001 From: Patrick Guiran Date: Sun, 1 Feb 2015 15:04:31 +0100 Subject: [PATCH 07/10] don't use traits, as php 5.3 doesn't support them --- .../Service/SeparatorToSeparatorFactory.php | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Word/Service/SeparatorToSeparatorFactory.php b/src/Word/Service/SeparatorToSeparatorFactory.php index 65c89111..7a80a061 100644 --- a/src/Word/Service/SeparatorToSeparatorFactory.php +++ b/src/Word/Service/SeparatorToSeparatorFactory.php @@ -5,14 +5,16 @@ use Zend\Filter\Word\SeparatorToSeparator; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\MutableCreationOptionsInterface; -use Zend\ServiceManager\MutableCreationOptionsTrait; use Zend\ServiceManager\ServiceLocatorInterface; class SeparatorToSeparatorFactory implements FactoryInterface, MutableCreationOptionsInterface { - use MutableCreationOptionsTrait; + /** + * @var array + */ + protected $creationOptions = array(); /** * Constructor. @@ -24,6 +26,27 @@ public function __construct(array $options = array()) $this->setCreationOptions($options); } + /** + * Set creation options + * + * @param array $creationOptions + * @return void + */ + public function setCreationOptions(array $creationOptions) + { + $this->creationOptions = $creationOptions; + } + + /** + * Get creation options + * + * @return array + */ + public function getCreationOptions() + { + return $this->creationOptions; + } + /** * {@inheritDoc} * From 45ab830acdf75741767726523dd2b01065ce8d93 Mon Sep 17 00:00:00 2001 From: Patrick Guiran Date: Sun, 1 Feb 2015 21:54:08 +0100 Subject: [PATCH 08/10] add @group 7169 --- test/FilterPluginManagerTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/FilterPluginManagerTest.php b/test/FilterPluginManagerTest.php index 18f5af64..88e873b5 100644 --- a/test/FilterPluginManagerTest.php +++ b/test/FilterPluginManagerTest.php @@ -40,6 +40,9 @@ public function testLoadingInvalidFilterRaisesException() $this->filters->get('test'); } + /** + * @group 7169 + */ public function testFilterSuccessfullyConstructed() { $search_separator = ';'; @@ -54,6 +57,9 @@ public function testFilterSuccessfullyConstructed() $this->assertEquals('|', $filter->getReplacementSeparator()); } + /** + * @group 7169 + */ public function testFiltersConstructedAreDifferent() { $filterOne = $this->filters->get( From e279ad6290f6887d83f1fc6ac413402e605af5ea Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 2 Feb 2015 02:58:30 +0000 Subject: [PATCH 09/10] zendframework/zf2#7169 zendframework/zf2#6666 - removing duplicate filter entry from plugin manager --- src/FilterPluginManager.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/FilterPluginManager.php b/src/FilterPluginManager.php index 47850b73..481e0bdf 100644 --- a/src/FilterPluginManager.php +++ b/src/FilterPluginManager.php @@ -84,7 +84,6 @@ class FilterPluginManager extends AbstractPluginManager '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', 'wordunderscoretostudlycase' => 'Zend\Filter\Word\UnderscoreToStudlyCase', 'wordunderscoretodash' => 'Zend\Filter\Word\UnderscoreToDash', From cc9937e28abd46c944d174d6e58fbfa8aea56ed0 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 2 Feb 2015 02:59:31 +0000 Subject: [PATCH 10/10] zendframework/zf2#7169 zendframework/zf2#6666 - removing redundant factory constructor --- src/Word/Service/SeparatorToSeparatorFactory.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/Word/Service/SeparatorToSeparatorFactory.php b/src/Word/Service/SeparatorToSeparatorFactory.php index 7a80a061..148ac3b0 100644 --- a/src/Word/Service/SeparatorToSeparatorFactory.php +++ b/src/Word/Service/SeparatorToSeparatorFactory.php @@ -16,16 +16,6 @@ class SeparatorToSeparatorFactory implements */ protected $creationOptions = array(); - /** - * Constructor. - * - * @param array $options - */ - public function __construct(array $options = array()) - { - $this->setCreationOptions($options); - } - /** * Set creation options *