Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
Zend_Filter_PregReplace Class Reference
Inheritance diagram for Zend_Filter_PregReplace:
Zend_Filter_Interface Zend_Filter_Word_Separator_Abstract Zend_Filter_Word_SeparatorToSeparator Zend_Filter_Word_CamelCaseToSeparator Zend_Filter_Word_DashToSeparator Zend_Filter_Word_SeparatorToCamelCase Zend_Filter_Word_DashToUnderscore Zend_Filter_Word_SeparatorToDash Zend_Filter_Word_UnderscoreToDash Zend_Filter_Word_UnderscoreToSeparator Zend_Filter_Word_CamelCaseToDash Zend_Filter_Word_CamelCaseToUnderscore Zend_Filter_Word_DashToCamelCase Zend_Filter_Word_UnderscoreToCamelCase

Public Member Functions

 __construct ($options=null)
 
 setMatchPattern ($match)
 
 getMatchPattern ()
 
 setReplacement ($replacement)
 
 getReplacement ()
 
 filter ($value)
 

Static Public Member Functions

static isUnicodeSupportEnabled ()
 

Static Protected Member Functions

static _determineUnicodeSupport ()
 

Protected Attributes

 $_matchPattern = null
 
 $_replacement = ''
 

Static Protected Attributes

static $_unicodeSupportEnabled = null
 

Detailed Description

Definition at line 33 of file PregReplace.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $options = null)

Constructor Supported options are 'match' => matching pattern 'replace' => replace with this

Parameters
string | array$options
Returns
void

Definition at line 87 of file PregReplace.php.

88  {
89  if ($options instanceof Zend_Config) {
90  $options = $options->toArray();
91  } else if (!is_array($options)) {
92  $options = func_get_args();
93  $temp = array();
94  if (!empty($options)) {
95  $temp['match'] = array_shift($options);
96  }
97 
98  if (!empty($options)) {
99  $temp['replace'] = array_shift($options);
100  }
101 
102  $options = $temp;
103  }
104 
105  if (array_key_exists('match', $options)) {
106  $this->setMatchPattern($options['match']);
107  }
108 
109  if (array_key_exists('replace', $options)) {
110  $this->setReplacement($options['replace']);
111  }
112  }
setReplacement($replacement)

Member Function Documentation

◆ _determineUnicodeSupport()

static _determineUnicodeSupport ( )
staticprotected

Method to cache the regex needed to determine if unicode support is available

Returns
bool

Definition at line 73 of file PregReplace.php.

74  {
75  self::$_unicodeSupportEnabled = (@preg_match('/\pL/u', 'a')) ? true : false;
76  }

◆ filter()

filter (   $value)

Perform regexp replacement as filter

Parameters
string$value
Returns
string

Implements Zend_Filter_Interface.

Definition at line 164 of file PregReplace.php.

165  {
166  if ($this->_matchPattern == null) {
167  #require_once 'Zend/Filter/Exception.php';
168  throw new Zend_Filter_Exception(get_class($this) . ' does not have a valid MatchPattern set.');
169  }
170 
171  return preg_replace($this->_matchPattern, $this->_replacement, $value);
172  }
$value
Definition: gender.phtml:16

◆ getMatchPattern()

getMatchPattern ( )

Get currently set match pattern

Returns
string

Definition at line 131 of file PregReplace.php.

132  {
133  return $this->_matchPattern;
134  }

◆ getReplacement()

getReplacement ( )

Get currently set replacement value

Returns
string

Definition at line 153 of file PregReplace.php.

154  {
155  return $this->_replacement;
156  }

◆ isUnicodeSupportEnabled()

static isUnicodeSupportEnabled ( )
static

Is Unicode Support Enabled Utility function

Returns
bool

Definition at line 59 of file PregReplace.php.

60  {
61  if (self::$_unicodeSupportEnabled === null) {
63  }
64 
66  }
static _determineUnicodeSupport()
Definition: PregReplace.php:73

◆ setMatchPattern()

setMatchPattern (   $match)

Set the match pattern for the regex being called within filter()

Parameters
mixed$match- same as the first argument of preg_replace
Returns
Zend_Filter_PregReplace

Definition at line 120 of file PregReplace.php.

121  {
122  $this->_matchPattern = $match;
123  return $this;
124  }

◆ setReplacement()

setReplacement (   $replacement)

Set the Replacement pattern/string for the preg_replace called in filter

Parameters
mixed$replacement- same as the second argument of preg_replace
Returns
Zend_Filter_PregReplace

Definition at line 142 of file PregReplace.php.

143  {
144  $this->_replacement = $replacement;
145  return $this;
146  }
$replacement
Definition: website.php:23

Field Documentation

◆ $_matchPattern

$_matchPattern = null
protected

Definition at line 39 of file PregReplace.php.

◆ $_replacement

$_replacement = ''
protected

Definition at line 45 of file PregReplace.php.

◆ $_unicodeSupportEnabled

$_unicodeSupportEnabled = null
staticprotected

Definition at line 52 of file PregReplace.php.


The documentation for this class was generated from the following file: