class File in Plug 7
@Target({"PROPERTY", "METHOD", "ANNOTATION"})
@author Bernhard Schussek <bschussek@gmail.com>
@api
Hierarchy
- class \Symfony\Component\Validator\Constraint
- class \Symfony\Component\Validator\Constraints\File
Expanded class hierarchy of File
3 files declare their use of File
- FileTest.php in lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Tests/ Constraints/ FileTest.php - FileValidatorPathTest.php in lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Tests/ Constraints/ FileValidatorPathTest.php - FileValidatorTest.php in lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Tests/ Constraints/ FileValidatorTest.php
File
- lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Constraints/ File.php, line 25
Namespace
Symfony\Component\Validator\ConstraintsView source
class File extends Constraint {
// Check the Image constraint for clashes if adding new constants here
const NOT_FOUND_ERROR = 1;
const NOT_READABLE_ERROR = 2;
const EMPTY_ERROR = 3;
const TOO_LARGE_ERROR = 4;
const INVALID_MIME_TYPE_ERROR = 5;
protected static $errorNames = array(
self::NOT_FOUND_ERROR => 'NOT_FOUND_ERROR',
self::NOT_READABLE_ERROR => 'NOT_READABLE_ERROR',
self::EMPTY_ERROR => 'EMPTY_ERROR',
self::TOO_LARGE_ERROR => 'TOO_LARGE_ERROR',
self::INVALID_MIME_TYPE_ERROR => 'INVALID_MIME_TYPE_ERROR',
);
public $maxSize;
public $binaryFormat;
public $mimeTypes = array();
public $notFoundMessage = 'The file could not be found.';
public $notReadableMessage = 'The file is not readable.';
public $maxSizeMessage = 'The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}.';
public $mimeTypesMessage = 'The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}.';
public $disallowEmptyMessage = 'An empty file is not allowed.';
public $uploadIniSizeErrorMessage = 'The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}.';
public $uploadFormSizeErrorMessage = 'The file is too large.';
public $uploadPartialErrorMessage = 'The file was only partially uploaded.';
public $uploadNoFileErrorMessage = 'No file was uploaded.';
public $uploadNoTmpDirErrorMessage = 'No temporary folder was configured in php.ini.';
public $uploadCantWriteErrorMessage = 'Cannot write temporary file to disk.';
public $uploadExtensionErrorMessage = 'A PHP extension caused the upload to fail.';
public $uploadErrorMessage = 'The file could not be uploaded.';
public function __construct($options = null) {
parent::__construct($options);
if ($this->maxSize) {
if (ctype_digit((string) $this->maxSize)) {
$this->maxSize = (int) $this->maxSize;
$this->binaryFormat = null === $this->binaryFormat ? false : $this->binaryFormat;
}
elseif (preg_match('/^\\d++k$/i', $this->maxSize)) {
$this->maxSize = $this->maxSize * 1000;
$this->binaryFormat = null === $this->binaryFormat ? false : $this->binaryFormat;
}
elseif (preg_match('/^\\d++M$/i', $this->maxSize)) {
$this->maxSize = $this->maxSize * 1000000;
$this->binaryFormat = null === $this->binaryFormat ? false : $this->binaryFormat;
}
elseif (preg_match('/^\\d++Ki$/i', $this->maxSize)) {
$this->maxSize = $this->maxSize << 10;
$this->binaryFormat = null === $this->binaryFormat ? true : $this->binaryFormat;
}
elseif (preg_match('/^\\d++Mi$/i', $this->maxSize)) {
$this->maxSize = $this->maxSize << 20;
$this->binaryFormat = null === $this->binaryFormat ? true : $this->binaryFormat;
}
else {
throw new ConstraintDefinitionException(sprintf('"%s" is not a valid maximum size', $this->maxSize));
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Constraint:: |
public | property | Domain-specific data attached to a constraint | |
Constraint:: |
public | function | Adds the given group if this constraint is in the Default group. | 1 |
Constraint:: |
constant | Marks a constraint that can be put onto classes. | ||
Constraint:: |
constant | The name of the group given to all constraints with no explicit group. | ||
Constraint:: |
public | function | Returns the name of the default option. | 15 |
Constraint:: |
public static | function | Returns the name of the given error code. | |
Constraint:: |
public | function | Returns the name of the required options. | 7 |
Constraint:: |
public | function | Returns whether the constraint can be put onto classes, properties or both. | 11 |
Constraint:: |
constant | Marks a constraint that can be put onto properties. | ||
Constraint:: |
public | function | Returns the name of the class that validates this constraint. | 1 |
Constraint:: |
public | function | Returns the value of a lazily initialized option. | |
Constraint:: |
public | function | Sets the value of a lazily initialized option. | |
Constraint:: |
public | function | Optimizes the serialized value to minimize storage space. | |
File:: |
public | property | ||
File:: |
public | property | ||
File:: |
protected static | property |
Maps error codes to the names of their constants Overrides Constraint:: |
1 |
File:: |
public | property | ||
File:: |
public | property | ||
File:: |
public | property | 1 | |
File:: |
public | property | 1 | |
File:: |
public | property | ||
File:: |
public | property | ||
File:: |
public | property | ||
File:: |
public | property | ||
File:: |
public | property | ||
File:: |
public | property | ||
File:: |
public | property | ||
File:: |
public | property | ||
File:: |
public | property | ||
File:: |
public | property | ||
File:: |
constant | |||
File:: |
constant | |||
File:: |
constant | |||
File:: |
constant | |||
File:: |
constant | |||
File:: |
public | function |
Initializes the constraint with options. Overrides Constraint:: |