Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
3ef20e59
Commit
3ef20e59
authored
Nov 05, 2013
by
Gudz Taras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Overriding validateFile()
parent
c8596fdb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
17 deletions
+5
-17
ImageValidator.php
framework/yii/validators/ImageValidator.php
+5
-17
No files found.
framework/yii/validators/ImageValidator.php
View file @
3ef20e59
...
@@ -140,28 +140,16 @@ class ImageValidator extends FileValidator
...
@@ -140,28 +140,16 @@ class ImageValidator extends FileValidator
}
}
/**
/**
* Validates the attribute of the object using {@link validateImage}.
* Internally validates a file object.
* If there is any error, the error message is added to the object.
* @param \yii\base\Model $object the object being validated
* @param \yii\base\Model $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
* @param UploadedFile $file uploaded file passed to check against a set of rules
*/
*/
p
ublic
function
validateAttribute
(
$object
,
$attribut
e
)
p
rotected
function
validateFile
(
$object
,
$attribute
,
$fil
e
)
{
{
parent
::
validateAttribute
(
$object
,
$attribute
);
parent
::
validateFile
(
$object
,
$attribute
,
$file
);
if
(
$object
->
hasErrors
())
{
return
;
}
if
(
$this
->
maxFiles
>
1
)
{
if
(
false
===
$object
->
hasErrors
(
$attribute
))
{
$files
=
$object
->
$attribute
;
$object
->
$attribute
=
array_values
(
$files
);
foreach
(
$files
as
$file
)
{
$this
->
validateImage
(
$object
,
$attribute
,
$file
);
}
}
else
{
$file
=
$object
->
$attribute
;
$this
->
validateImage
(
$object
,
$attribute
,
$file
);
$this
->
validateImage
(
$object
,
$attribute
,
$file
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment