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

Public Member Functions

 __construct ($options)
 
 getMd5 ()
 
 setHash ($options)
 
 setMd5 ($options)
 
 addHash ($options)
 
 addMd5 ($options)
 
 isValid ($value, $file=null)
 
- Public Member Functions inherited from Zend_Validate_File_Hash
 __construct ($options)
 
 getHash ()
 
 setHash ($options)
 
 addHash ($options)
 
 isValid ($value, $file=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 DOES_NOT_MATCH = 'fileMd5DoesNotMatch'
 
const NOT_DETECTED = 'fileMd5NotDetected'
 
const NOT_FOUND = 'fileMd5NotFound'
 
- Data Fields inherited from Zend_Validate_File_Hash
const DOES_NOT_MATCH = 'fileHashDoesNotMatch'
 
const NOT_DETECTED = 'fileHashHashNotDetected'
 
const NOT_FOUND = 'fileHashNotFound'
 

Protected Attributes

 $_messageTemplates
 
 $_hash
 
- Protected Attributes inherited from Zend_Validate_File_Hash
 $_messageTemplates
 
 $_hash
 
- 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_File_Hash
 _throw ($file, $errorType)
 
- 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 35 of file Md5.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $options)

Sets validator options

$hash is the hash we accept for the file $file

Parameters
string | array$options
Exceptions
Zend_Validate_Exception
Returns
Zend_Validate_File_Md5

Definition at line 69 of file Md5.php.

70  {
71  if ($options instanceof Zend_Config) {
72  $options = $options->toArray();
73  } elseif (is_scalar($options)) {
74  $options = array('hash1' => $options);
75  } elseif (!is_array($options)) {
76  #require_once 'Zend/Validate/Exception.php';
77  throw new Zend_Validate_Exception('Invalid options to validator provided');
78  }
79 
80  $this->setMd5($options);
81  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
setMd5($options)
Definition: Md5.php:116

Member Function Documentation

◆ addHash()

addHash (   $options)

Adds the md5 hash for one or multiple files

Parameters
string | array$options
Returns
Zend_Validate_File_Hash Provides a fluent interface

Definition at line 128 of file Md5.php.

129  {
130  if (!is_array($options)) {
131  $options = (array) $options;
132  }
133 
134  $options['algorithm'] = 'md5';
135  parent::addHash($options);
136  return $this;
137  }

◆ addMd5()

addMd5 (   $options)

Adds the md5 hash for one or multiple files

Parameters
string | array$options
Returns
Zend_Validate_File_Hash Provides a fluent interface

Definition at line 145 of file Md5.php.

146  {
147  $this->addHash($options);
148  return $this;
149  }
addHash($options)
Definition: Md5.php:128

◆ getMd5()

getMd5 ( )

Returns all set md5 hashes

Returns
array

Definition at line 88 of file Md5.php.

89  {
90  return $this->getHash();
91  }

◆ isValid()

isValid (   $value,
  $file = null 
)

Defined by Zend_Validate_Interface

Returns true if and only if the given file confirms the set hash

Parameters
string$valueFilename to check for hash
array$fileFile data from Zend_File_Transfer
Returns
boolean

Definition at line 160 of file Md5.php.

161  {
162  // Is file readable ?
163  #require_once 'Zend/Loader.php';
165  return $this->_throw($file, self::NOT_FOUND);
166  }
167 
168  $hashes = array_unique(array_keys($this->_hash));
169  $filehash = hash_file('md5', $value);
170  if ($filehash === false) {
171  return $this->_throw($file, self::NOT_DETECTED);
172  }
173 
174  foreach($hashes as $hash) {
175  if ($filehash === $hash) {
176  return true;
177  }
178  }
179 
180  return $this->_throw($file, self::DOES_NOT_MATCH);
181  }
static isReadable($filename)
Definition: Loader.php:162
$value
Definition: gender.phtml:16
_throw($file, $errorType)
Definition: Hash.php:186

◆ setHash()

setHash (   $options)

Sets the md5 hash for one or multiple files

Parameters
string | array$options
Returns
Zend_Validate_File_Hash Provides a fluent interface

Definition at line 99 of file Md5.php.

100  {
101  if (!is_array($options)) {
102  $options = (array) $options;
103  }
104 
105  $options['algorithm'] = 'md5';
106  parent::setHash($options);
107  return $this;
108  }

◆ setMd5()

setMd5 (   $options)

Sets the md5 hash for one or multiple files

Parameters
string | array$options
Returns
Zend_Validate_File_Hash Provides a fluent interface

Definition at line 116 of file Md5.php.

117  {
118  $this->setHash($options);
119  return $this;
120  }
setHash($options)
Definition: Md5.php:99

Field Documentation

◆ $_hash

$_hash
protected

Definition at line 58 of file Md5.php.

◆ $_messageTemplates

$_messageTemplates
protected
Initial value:
= array(
self::DOES_NOT_MATCH => "File '%value%' does not match the given md5 hashes",
self::NOT_DETECTED => "A md5 hash could not be evaluated for the given file",
self::NOT_FOUND => "File '%value%' is not readable or does not exist",
)

Definition at line 47 of file Md5.php.

◆ DOES_NOT_MATCH

const DOES_NOT_MATCH = 'fileMd5DoesNotMatch'

@const string Error constants

Definition at line 40 of file Md5.php.

◆ NOT_DETECTED

const NOT_DETECTED = 'fileMd5NotDetected'

Definition at line 41 of file Md5.php.

◆ NOT_FOUND

const NOT_FOUND = 'fileMd5NotFound'

Definition at line 42 of file Md5.php.


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