Definition at line 35 of file Count.php.
◆ __construct()
Sets validator options
Min limits the file count, when used with max=null it is the maximum file count It also accepts an array with the keys 'min' and 'max'
If $options is a integer, it will be used as maximum file count As Array is accepts the following keys: 'min': Minimum filecount 'max': Maximum filecount
- Parameters
-
integer | array | Zend_Config | $options | Options for the adapter |
- Exceptions
-
Definition at line 106 of file Count.php.
113 #require_once 'Zend/Validate/Exception.php'; 117 if (1 < func_num_args()) {
elseif(isset( $params[ 'redirect_parent']))
◆ _throw()
_throw |
( |
|
$file, |
|
|
|
$errorType |
|
) |
| |
|
protected |
Throws an error of the given type
- Parameters
-
string | $file | |
string | $errorType | |
- Returns
- false
Definition at line 276 of file Count.php.
278 if ($file !==
null) {
279 $this->_value = $file[
'name'];
282 $this->
_error($errorType);
_error($messageKey, $value=null)
◆ addFile()
Adds a file for validation
- Parameters
-
- Returns
- $this
Definition at line 215 of file Count.php.
217 if (is_string($file)) {
218 $file = array($file);
221 if (is_array($file)) {
222 foreach ($file as
$name) {
223 if (!isset($this->_files[
$name]) && !empty(
$name)) {
if(!isset($_GET['name'])) $name
◆ getMax()
Returns the maximum file count
- Returns
- integer
Definition at line 175 of file Count.php.
◆ getMin()
Returns the minimum file count
- Returns
- integer
Definition at line 136 of file Count.php.
◆ isValid()
isValid |
( |
|
$value, |
|
|
|
$file = null |
|
) |
| |
Defined by Zend_Validate_Interface
Returns true if and only if the file count of all checked files is at least min and not bigger than max (when max is not null). Attention: When checking with set min you must give all files with the first call, otherwise you will get an false.
- Parameters
-
string | array | $value | Filenames to check for count |
array | $file | File data from Zend_File_Transfer |
- Returns
- boolean
Definition at line 243 of file Count.php.
245 if (($file !==
null) && !array_key_exists(
'destination', $file)) {
246 $file[
'destination'] = dirname(
$value);
249 if (($file !==
null) && array_key_exists(
'tmp_name', $file)) {
250 $value = $file[
'destination'] . DIRECTORY_SEPARATOR . $file[
'name'];
253 if (($file ===
null) || !empty($file[
'tmp_name'])) {
257 $this->_count = count($this->_files);
258 if (($this->_max !==
null) && ($this->_count > $this->_max)) {
259 return $this->
_throw($file, self::TOO_MANY);
262 if (($this->_min !==
null) && ($this->_count < $this->_min)) {
263 return $this->
_throw($file, self::TOO_FEW);
_throw($file, $errorType)
◆ setMax()
Sets the maximum file count
- Parameters
-
integer | array | $max | The maximum file count |
- Returns
- Zend_Validate_StringLength Provides a fluent interface
- Exceptions
-
Definition at line 187 of file Count.php.
189 if (is_array($max) and isset($max[
'max'])) {
193 if (!is_string($max) and !is_numeric($max)) {
194 #require_once 'Zend/Validate/Exception.php'; 198 $max = (integer) $max;
199 if (($this->_min !==
null) && ($max <
$this->_min)) {
200 #require_once 'Zend/Validate/Exception.php'; 202 .
"$max < {$this->_min}");
◆ setMin()
Sets the minimum file count
- Parameters
-
integer | array | $min | The minimum file count |
- Returns
- Zend_Validate_File_Count Provides a fluent interface
- Exceptions
-
Definition at line 148 of file Count.php.
150 if (is_array($min) and isset($min[
'min'])) {
154 if (!is_string($min) and !is_numeric($min)) {
155 #require_once 'Zend/Validate/Exception.php'; 159 $min = (integer) $min;
160 if (($this->_max !==
null) && ($min >
$this->_max)) {
161 #require_once 'Zend/Validate/Exception.php'; 162 throw new Zend_Validate_Exception(
"The minimum must be less than or equal to the maximum file count, but $min >"
◆ $_count
◆ $_files
◆ $_max
◆ $_messageTemplates
Initial value:= array(
self::TOO_MANY => "Too many files, maximum '%max%' are allowed but '%count%' are given",
self::TOO_FEW => "Too few files, minimum '%min%' are expected but '%count%' are given",
)
Definition at line 47 of file Count.php.
◆ $_messageVariables
Initial value:= array(
'min' => '_min',
'max' => '_max',
'count' => '_count'
)
Definition at line 55 of file Count.php.
◆ $_min
◆ TOO_FEW
const TOO_FEW = 'fileCountTooFew' |
◆ TOO_MANY
const TOO_MANY = 'fileCountTooMany' |
#+ @const string Error constants
Definition at line 40 of file Count.php.
The documentation for this class was generated from the following file:
- vendor/magento/zendframework1/library/Zend/Validate/File/Count.php