I would like to use the SeparatorToSeparator () filter in zend framwork 2 to filter my data.
How to pass two arguments (setSearchSeparator and setReplacementSeparator) to the constructor?
$inputFilter->add(array( 'name' => 'supplierName', 'required' => true, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), array('name'=>"Word\SeparatorToSeparator" ), ));
Path: ZendFramework / bin / libary / Zend / Filter / Word / SeparatorToSeparator.php
class SeparatorToSeparator extends AbstractFilter { protected $searchSeparator = null; protected $replacementSeparator = null; public function __construct($searchSeparator = ' ', $replacementSeparator = '-') { $this->setSearchSeparator($searchSeparator); $this->setReplacementSeparator($replacementSeparator); }
Update
$inputFilter->add(array( 'name' => 'supplierName', 'required' => true, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), array('name'=>'Word\SeparatorToSeparator', 'options' => array( 'search_separator' => 'a', 'replacement_separator' => 'b' ) ) ), ));
I got this error message:
Warning: preg_quote () expects parameter 1 to be a string, the array is specified in C: \ WAMP \ WWW \ tebipdevelopment \ provider \ ZendFramework \ ZendFramework \ Library \ Zend \ Filter \ Word \ SeparatorToSeparator.php on line 92
I opened this line and I printed the error message as follows.
print_r($this->searchSeparator); print_r($this->replacementSeparator);
Result
Array ([search_separator] => a [replacement_separator] => b)
In this case, search_separator is equal to an array instead of a string