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

Public Member Functions

 isValid ($value, $file=null)
 
- Public Member Functions inherited from Zend_Validate_File_MimeType
 __construct ($mimetype)
 
 getMagicFile ()
 
 setMagicFile ($file)
 
 setTryCommonMagicFilesFlag ($flag=true)
 
 shouldTryCommonMagicFiles ()
 
 getHeaderCheck ()
 
 enableHeaderCheck ($headerCheck=true)
 
 getMimeType ($asArray=false)
 
 setMimeType ($mimetype)
 
 addMimeType ($mimetype)
 
 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_TYPE = 'fileExcludeMimeTypeFalse'
 
const NOT_DETECTED = 'fileExcludeMimeTypeNotDetected'
 
const NOT_READABLE = 'fileExcludeMimeTypeNotReadable'
 
- Data Fields inherited from Zend_Validate_File_MimeType
const FALSE_TYPE = 'fileMimeTypeFalse'
 
const NOT_DETECTED = 'fileMimeTypeNotDetected'
 
const NOT_READABLE = 'fileMimeTypeNotReadable'
 

Protected Attributes

 $_messageTemplates
 
- Protected Attributes inherited from Zend_Validate_File_MimeType
 $_messageTemplates
 
 $_messageVariables
 
 $_type
 
 $_mimetype
 
 $_magicfile
 
 $_finfo
 
 $_magicFiles
 
 $_tryCommonMagicFiles = true
 
 $_headerCheck = false
 
 $_finfoError
 
- 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_MimeType
 _throw ($file, $errorType)
 
 _detectMimeType ($file)
 
 _errorHandler ($errno, $errstr, $errfile, $errline)
 
- 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 ExcludeMimeType.php.

Member Function Documentation

◆ isValid()

isValid (   $value,
  $file = null 
)

Defined by Zend_Validate_Interface

Returns true if the mimetype of the file does not matche the given ones. Also parts of mimetypes can be checked. If you give for example "image" all image mime types will not be accepted like "image/gif", "image/jpeg" and so on.

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

Definition at line 61 of file ExcludeMimeType.php.

62  {
63  if ($file === null) {
64  $file = array(
65  'type' => null,
66  'name' => $value
67  );
68  }
69 
70  // Is file readable ?
71  #require_once 'Zend/Loader.php';
73  return $this->_throw($file, self::NOT_READABLE);
74  }
75 
76  $this->_type = $this->_detectMimeType($value);
77 
78  if (empty($this->_type) && $this->_headerCheck) {
79  $this->_type = $file['type'];
80  }
81 
82  if (empty($this->_type)) {
83  return $this->_throw($file, self::NOT_DETECTED);
84  }
85 
86  $mimetype = $this->getMimeType(true);
87  if (in_array($this->_type, $mimetype)) {
88  return $this->_throw($file, self::FALSE_TYPE);
89  }
90 
91  $types = explode('/', $this->_type);
92  $types = array_merge($types, explode('-', $this->_type));
93  foreach($mimetype as $mime) {
94  if (in_array($mime, $types)) {
95  return $this->_throw($file, self::FALSE_TYPE);
96  }
97  }
98 
99  return true;
100  }
_throw($file, $errorType)
Definition: MimeType.php:419
static isReadable($filename)
Definition: Loader.php:162
$value
Definition: gender.phtml:16
getMimeType($asArray=false)
Definition: MimeType.php:293

Field Documentation

◆ $_messageTemplates

$_messageTemplates
protected
Initial value:
= array(
self::FALSE_TYPE => "File '%value%' has a false mimetype of '%type%'",
self::NOT_DETECTED => "The mimetype of file '%value%' could not be detected",
self::NOT_READABLE => "File '%value%' is not readable or does not exist",
)

Definition at line 44 of file ExcludeMimeType.php.

◆ FALSE_TYPE

const FALSE_TYPE = 'fileExcludeMimeTypeFalse'

Definition at line 37 of file ExcludeMimeType.php.

◆ NOT_DETECTED

const NOT_DETECTED = 'fileExcludeMimeTypeNotDetected'

Definition at line 38 of file ExcludeMimeType.php.

◆ NOT_READABLE

const NOT_READABLE = 'fileExcludeMimeTypeNotReadable'

Definition at line 39 of file ExcludeMimeType.php.


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