Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
Zend_Validate_Identical Class Reference
Inheritance diagram for Zend_Validate_Identical:
Zend_Validate_Abstract Zend_Validate_Interface

Public Member Functions

 __construct ($token=null)
 
 getToken ()
 
 setToken ($token)
 
 getStrict ()
 
 setStrict ($strict)
 
 isValid ($value, $context=null)
 
- Public Member Functions inherited from Zend_Validate_Abstract
 getMessages ()
 
 getMessageVariables ()
 
 getMessageTemplates ()
 
 setMessage ($messageString, $messageKey=null)
 
 setMessages (array $messages)
 
 __get ($property)
 
 getErrors ()
 
 setObscureValue ($flag)
 
 getObscureValue ()
 
 setTranslator ($translator=null)
 
 getTranslator ()
 
 hasTranslator ()
 
 setDisableTranslator ($flag)
 
 translatorIsDisabled ()
 
- Public Member Functions inherited from Zend_Validate_Interface
 isValid ($value)
 

Data Fields

const NOT_SAME = 'notSame'
 
const MISSING_TOKEN = 'missingToken'
 

Protected Attributes

 $_messageTemplates
 
 $_messageVariables
 
 $_tokenString
 
 $_token
 
 $_strict = true
 
- Protected Attributes inherited from Zend_Validate_Abstract
 $_value
 
 $_messageVariables = array()
 
 $_messageTemplates = array()
 
 $_messages = array()
 
 $_obscureValue = false
 
 $_errors = array()
 
 $_translator
 
 $_translatorDisabled = false
 

Additional Inherited Members

- Static Public Member Functions inherited from Zend_Validate_Abstract
static setDefaultTranslator ($translator=null)
 
static getDefaultTranslator ()
 
static hasDefaultTranslator ()
 
static getMessageLength ()
 
static setMessageLength ($length=-1)
 
- Protected Member Functions inherited from Zend_Validate_Abstract
 _createMessage ($messageKey, $value)
 
 _implodeRecursive (array $pieces)
 
 _error ($messageKey, $value=null)
 
 _setValue ($value)
 
- Static Protected Attributes inherited from Zend_Validate_Abstract
static $_defaultTranslator
 
static $_messageLength = -1
 

Detailed Description

Definition at line 31 of file Identical.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $token = null)

Sets validator options

Parameters
mixed$token

Definition at line 69 of file Identical.php.

70  {
71  if ($token instanceof Zend_Config) {
72  $token = $token->toArray();
73  }
74 
75  if (is_array($token) && array_key_exists('token', $token)) {
76  if (array_key_exists('strict', $token)) {
77  $this->setStrict($token['strict']);
78  }
79 
80  $this->setToken($token['token']);
81  } else if (null !== $token) {
82  $this->setToken($token);
83  }
84  }

Member Function Documentation

◆ getStrict()

getStrict ( )

Returns the strict parameter

Returns
boolean

Definition at line 114 of file Identical.php.

115  {
116  return $this->_strict;
117  }

◆ getToken()

getToken ( )

Retrieve token

Returns
string

Definition at line 91 of file Identical.php.

92  {
93  return $this->_token;
94  }

◆ isValid()

isValid (   $value,
  $context = null 
)

Defined by Zend_Validate_Interface

Returns true if and only if a token has been set and the provided value matches that token.

Parameters
mixed$value
array$context
Returns
boolean

Definition at line 141 of file Identical.php.

142  {
143  $this->_setValue($value);
144 
145  if (($context !== null) && isset($context) && array_key_exists($this->getToken(), $context)) {
146  $token = $context[$this->getToken()];
147  } else {
148  $token = $this->getToken();
149  }
150 
151  if ($token === null) {
152  $this->_error(self::MISSING_TOKEN);
153  return false;
154  }
155 
156  $strict = $this->getStrict();
157  if (($strict && ($value !== $token)) || (!$strict && ($value != $token))) {
158  $this->_error(self::NOT_SAME);
159  return false;
160  }
161 
162  return true;
163  }
_error($messageKey, $value=null)
Definition: Abstract.php:284
$value
Definition: gender.phtml:16

◆ setStrict()

setStrict (   $strict)

Sets the strict parameter

Parameters
Zend_Validate_Identical
Returns
$this

Definition at line 125 of file Identical.php.

126  {
127  $this->_strict = (boolean) $strict;
128  return $this;
129  }

◆ setToken()

setToken (   $token)

Set token against which to compare

Parameters
mixed$token
Returns
Zend_Validate_Identical

Definition at line 102 of file Identical.php.

103  {
104  $this->_tokenString = $token;
105  $this->_token = $token;
106  return $this;
107  }

Field Documentation

◆ $_messageTemplates

$_messageTemplates
protected
Initial value:
= array(
self::NOT_SAME => "The two given tokens do not match",
self::MISSING_TOKEN => 'No token was provided to match against',
)

Definition at line 44 of file Identical.php.

◆ $_messageVariables

$_messageVariables
protected
Initial value:
= array(
'token' => '_tokenString'
)

Definition at line 52 of file Identical.php.

◆ $_strict

$_strict = true
protected

Definition at line 62 of file Identical.php.

◆ $_token

$_token
protected

Definition at line 61 of file Identical.php.

◆ $_tokenString

$_tokenString
protected

Definition at line 60 of file Identical.php.

◆ MISSING_TOKEN

const MISSING_TOKEN = 'missingToken'

Definition at line 38 of file Identical.php.

◆ NOT_SAME

const NOT_SAME = 'notSame'

Error codes @const string

Definition at line 37 of file Identical.php.


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