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

Public Member Functions

 __construct ($options)
 
 getCrc32 ()
 
 setHash ($options)
 
 setCrc32 ($options)
 
 addHash ($options)
 
 addCrc32 ($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 = 'fileCrc32DoesNotMatch'
 
const NOT_DETECTED = 'fileCrc32NotDetected'
 
const NOT_FOUND = 'fileCrc32NotFound'
 
- 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 Crc32.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $options)

Sets validator options

Parameters
string | array | Zend_Config$options
Exceptions
Zend_Validate_Exception
Returns
Zend_Validate_File_Crc32

Definition at line 67 of file Crc32.php.

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

Member Function Documentation

◆ addCrc32()

addCrc32 (   $options)

Adds the crc32 hash for one or multiple files

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

Definition at line 143 of file Crc32.php.

144  {
145  $this->addHash($options);
146  return $this;
147  }

◆ addHash()

addHash (   $options)

Adds the crc32 hash for one or multiple files

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

Definition at line 126 of file Crc32.php.

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

◆ getCrc32()

getCrc32 ( )

Returns all set crc32 hashes

Returns
array

Definition at line 86 of file Crc32.php.

87  {
88  return $this->getHash();
89  }

◆ 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 158 of file Crc32.php.

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

◆ setCrc32()

setCrc32 (   $options)

Sets the crc32 hash for one or multiple files

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

Definition at line 114 of file Crc32.php.

115  {
116  $this->setHash($options);
117  return $this;
118  }

◆ setHash()

setHash (   $options)

Sets the crc32 hash for one or multiple files

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

Definition at line 97 of file Crc32.php.

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

Field Documentation

◆ $_hash

$_hash
protected

Definition at line 58 of file Crc32.php.

◆ $_messageTemplates

$_messageTemplates
protected
Initial value:
= array(
self::DOES_NOT_MATCH => "File '%value%' does not match the given crc32 hashes",
self::NOT_DETECTED => "A crc32 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 Crc32.php.

◆ DOES_NOT_MATCH

const DOES_NOT_MATCH = 'fileCrc32DoesNotMatch'

@const string Error constants

Definition at line 40 of file Crc32.php.

◆ NOT_DETECTED

const NOT_DETECTED = 'fileCrc32NotDetected'

Definition at line 41 of file Crc32.php.

◆ NOT_FOUND

const NOT_FOUND = 'fileCrc32NotFound'

Definition at line 42 of file Crc32.php.


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