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

Public Member Functions

 isValid ($value, $file=null)
 
- Public Member Functions inherited from Zend_Validate_File_Extension
 __construct ($options)
 
 getCase ()
 
 setCase ($case)
 
 getExtension ()
 
 setExtension ($extension)
 
 addExtension ($extension)
 
 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 FALSE_EXTENSION = 'fileExcludeExtensionFalse'
 
const NOT_FOUND = 'fileExcludeExtensionNotFound'
 
- Data Fields inherited from Zend_Validate_File_Extension
const FALSE_EXTENSION = 'fileExtensionFalse'
 
const NOT_FOUND = 'fileExtensionNotFound'
 

Protected Attributes

 $_messageTemplates
 
- Protected Attributes inherited from Zend_Validate_File_Extension
 $_messageTemplates
 
 $_extension = ''
 
 $_case = false
 
 $_messageVariables
 
- 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_Extension
 _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 ExcludeExtension.php.

Member Function Documentation

◆ isValid()

isValid (   $value,
  $file = null 
)

Defined by Zend_Validate_Interface

Returns true if and only if the fileextension of $value is not included in the set extension list

Parameters
string$valueReal file to check for extension
array$fileFile data from Zend_File_Transfer
Returns
boolean

Definition at line 61 of file ExcludeExtension.php.

62  {
63  // Is file readable ?
64  #require_once 'Zend/Loader.php';
66  return $this->_throw($file, self::NOT_FOUND);
67  }
68 
69  if ($file !== null) {
70  $info['extension'] = substr($file['name'], strrpos($file['name'], '.') + 1);
71  } else {
72  $info = pathinfo($value);
73  }
74 
75  $extensions = $this->getExtension();
76 
77  if ($this->_case and (!in_array($info['extension'], $extensions))) {
78  return true;
79  } else if (!$this->_case) {
80  $found = false;
81  foreach ($extensions as $extension) {
82  if (strtolower($extension) == strtolower($info['extension'])) {
83  $found = true;
84  }
85  }
86 
87  if (!$found) {
88  return true;
89  }
90  }
91 
92  return $this->_throw($file, self::FALSE_EXTENSION);
93  }
static isReadable($filename)
Definition: Loader.php:162
$value
Definition: gender.phtml:16
_throw($file, $errorType)
Definition: Extension.php:228
foreach( $_productCollection as $_product)() ?>" class $info
Definition: listing.phtml:52

Field Documentation

◆ $_messageTemplates

$_messageTemplates
protected
Initial value:
= array(
self::FALSE_EXTENSION => "File '%value%' has a false extension",
self::NOT_FOUND => "File '%value%' is not readable or does not exist",
)

Definition at line 46 of file ExcludeExtension.php.

◆ FALSE_EXTENSION

const FALSE_EXTENSION = 'fileExcludeExtensionFalse'

@const string Error constants

Definition at line 40 of file ExcludeExtension.php.

◆ NOT_FOUND

const NOT_FOUND = 'fileExcludeExtensionNotFound'

Definition at line 41 of file ExcludeExtension.php.


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