updated-packages
This commit is contained in:
@@ -10,12 +10,15 @@
|
||||
namespace Zend\Validator\File;
|
||||
|
||||
use Zend\Validator\Exception;
|
||||
use Zend\Validator\File\FileInformationTrait;
|
||||
|
||||
/**
|
||||
* Validator which checks if the destination file does not exist
|
||||
*/
|
||||
class NotExists extends Exists
|
||||
{
|
||||
use FileInformationTrait;
|
||||
|
||||
/**
|
||||
* @const string Error constants
|
||||
*/
|
||||
@@ -37,31 +40,15 @@ class NotExists extends Exists
|
||||
*/
|
||||
public function isValid($value, $file = null)
|
||||
{
|
||||
if (is_string($value) && is_array($file)) {
|
||||
// Legacy Zend\Transfer API support
|
||||
$filename = $file['name'];
|
||||
$file = $file['tmp_name'];
|
||||
$this->setValue($filename);
|
||||
} elseif (is_array($value)) {
|
||||
if (! isset($value['tmp_name']) || ! isset($value['name'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Value array must be in $_FILES format'
|
||||
);
|
||||
}
|
||||
$file = $value['tmp_name'];
|
||||
$filename = basename($file);
|
||||
$this->setValue($value['name']);
|
||||
} else {
|
||||
$file = $value;
|
||||
$filename = basename($file);
|
||||
$this->setValue($filename);
|
||||
}
|
||||
$fileInfo = $this->getFileInfo($value, $file, false, true);
|
||||
|
||||
$this->setValue($fileInfo['filename']);
|
||||
|
||||
$check = false;
|
||||
$directories = $this->getDirectory(true);
|
||||
if (! isset($directories)) {
|
||||
$check = true;
|
||||
if (file_exists($file)) {
|
||||
if (file_exists($fileInfo['file'])) {
|
||||
$this->error(self::DOES_EXIST);
|
||||
return false;
|
||||
}
|
||||
@@ -72,7 +59,7 @@ class NotExists extends Exists
|
||||
}
|
||||
|
||||
$check = true;
|
||||
if (file_exists($directory . DIRECTORY_SEPARATOR . $filename)) {
|
||||
if (file_exists($directory . DIRECTORY_SEPARATOR . $fileInfo['basename'])) {
|
||||
$this->error(self::DOES_EXIST);
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user