Image
extends File
in package
Contains the properties of a constraint definition.
Tags
Table of Contents
- CLASS_CONSTRAINT = 'class'
- Marks a constraint that can be put onto classes.
- CORRUPTED_IMAGE_ERROR = '5d4163f3-648f-4e39-87fd-cc5ea7aad2d1'
- DEFAULT_GROUP = 'Default'
- The name of the group given to all constraints with no explicit group.
- EMPTY_ERROR = '5d743385-9775-4aa5-8ff5-495fb1e60137'
- INVALID_MIME_TYPE_ERROR = '744f00bc-4389-4c74-92de-9a43cde55534'
- LANDSCAPE_NOT_ALLOWED_ERROR = '6f895685-7cf2-4d65-b3da-9029c5581d88'
- NOT_FOUND_ERROR = 'd2a3fb6e-7ddc-4210-8fbf-2ab345ce1998'
- NOT_READABLE_ERROR = 'c20c92a4-5bfa-4202-9477-28e800e0f6ff'
- PORTRAIT_NOT_ALLOWED_ERROR = '65608156-77da-4c79-a88c-02ef6d18c782'
- PROPERTY_CONSTRAINT = 'property'
- Marks a constraint that can be put onto properties.
- RATIO_TOO_BIG_ERROR = '70cafca6-168f-41c9-8c8c-4e47a52be643'
- RATIO_TOO_SMALL_ERROR = '59b8c6ef-bcf2-4ceb-afff-4642ed92f12e'
- SIZE_NOT_DETECTED_ERROR = '6d55c3f4-e58e-4fe3-91ee-74b492199956'
- SQUARE_NOT_ALLOWED_ERROR = '5d41425b-facb-47f7-a55a-de9fbe45cb46'
- TOO_FEW_PIXEL_ERROR = '1b06b97d-ae48-474e-978f-038a74854c43'
- TOO_HIGH_ERROR = '7efae81c-4877-47ba-aa65-d01ccb0d4645'
- TOO_LARGE_ERROR = 'df8637af-d466-48c6-a59d-e7126250a654'
- TOO_LOW_ERROR = 'aef0cb6a-c07f-4894-bc08-1781420d7b4c'
- TOO_MANY_PIXEL_ERROR = 'ee0804e8-44db-4eac-9775-be91aaf72ce1'
- TOO_NARROW_ERROR = '9afbd561-4f90-4a27-be62-1780fc43604a'
- TOO_WIDE_ERROR = '7f87163d-878f-47f5-99ba-a8eb723a1ab2'
- $allowLandscape : mixed
- $allowLandscapeMessage : mixed
- $allowPortrait : mixed
- $allowPortraitMessage : mixed
- $allowSquare : mixed
- $allowSquareMessage : mixed
- $binaryFormat : mixed
- $corruptedMessage : mixed
- $detectCorrupted : mixed
- $disallowEmptyMessage : mixed
- $groups : array<string|int, string>
- The groups that the constraint belongs to.
- $maxHeight : mixed
- $maxHeightMessage : mixed
- $maxPixels : mixed
- $maxPixelsMessage : mixed
- $maxRatio : mixed
- $maxRatioMessage : mixed
- $maxSize : int
- $maxSizeMessage : mixed
- $maxWidth : mixed
- $maxWidthMessage : mixed
- $mimeTypes : mixed
- $mimeTypesMessage : mixed
- $minHeight : mixed
- $minHeightMessage : mixed
- $minPixels : mixed
- $minPixelsMessage : mixed
- $minRatio : mixed
- $minRatioMessage : mixed
- $minWidth : mixed
- $minWidthMessage : mixed
- $notFoundMessage : mixed
- $notReadableMessage : mixed
- $payload : mixed
- Domain-specific data attached to a constraint.
- $sizeNotDetectedMessage : mixed
- $uploadCantWriteErrorMessage : mixed
- $uploadErrorMessage : mixed
- $uploadExtensionErrorMessage : mixed
- $uploadFormSizeErrorMessage : mixed
- $uploadIniSizeErrorMessage : mixed
- $uploadNoFileErrorMessage : mixed
- $uploadNoTmpDirErrorMessage : mixed
- $uploadPartialErrorMessage : mixed
- $errorNames : mixed
- Maps error codes to the names of their constants.
- $maxSize : mixed
- __construct() : mixed
- Initializes the constraint with options.
- __get() : mixed
- __isset() : bool
- __set() : mixed
- Sets the value of a lazily initialized option.
- addImplicitGroupName() : mixed
- Adds the given group if this constraint is in the Default group.
- getDefaultOption() : string|null
- Returns the name of the default option.
- getErrorName() : string
- Returns the name of the given error code.
- getRequiredOptions() : array<string|int, string>
- Returns the name of the required options.
- getTargets() : string|array<string|int, string>
- Returns whether the constraint can be put onto classes, properties or both.
- validatedBy() : string
- Returns the name of the class that validates this constraint.
- normalizeBinaryFormat() : mixed
Constants
CLASS_CONSTRAINT
Marks a constraint that can be put onto classes.
public
mixed
CLASS_CONSTRAINT
= 'class'
CORRUPTED_IMAGE_ERROR
public
mixed
CORRUPTED_IMAGE_ERROR
= '5d4163f3-648f-4e39-87fd-cc5ea7aad2d1'
DEFAULT_GROUP
The name of the group given to all constraints with no explicit group.
public
mixed
DEFAULT_GROUP
= 'Default'
EMPTY_ERROR
public
mixed
EMPTY_ERROR
= '5d743385-9775-4aa5-8ff5-495fb1e60137'
INVALID_MIME_TYPE_ERROR
public
mixed
INVALID_MIME_TYPE_ERROR
= '744f00bc-4389-4c74-92de-9a43cde55534'
LANDSCAPE_NOT_ALLOWED_ERROR
public
mixed
LANDSCAPE_NOT_ALLOWED_ERROR
= '6f895685-7cf2-4d65-b3da-9029c5581d88'
NOT_FOUND_ERROR
public
mixed
NOT_FOUND_ERROR
= 'd2a3fb6e-7ddc-4210-8fbf-2ab345ce1998'
NOT_READABLE_ERROR
public
mixed
NOT_READABLE_ERROR
= 'c20c92a4-5bfa-4202-9477-28e800e0f6ff'
PORTRAIT_NOT_ALLOWED_ERROR
public
mixed
PORTRAIT_NOT_ALLOWED_ERROR
= '65608156-77da-4c79-a88c-02ef6d18c782'
PROPERTY_CONSTRAINT
Marks a constraint that can be put onto properties.
public
mixed
PROPERTY_CONSTRAINT
= 'property'
RATIO_TOO_BIG_ERROR
public
mixed
RATIO_TOO_BIG_ERROR
= '70cafca6-168f-41c9-8c8c-4e47a52be643'
RATIO_TOO_SMALL_ERROR
public
mixed
RATIO_TOO_SMALL_ERROR
= '59b8c6ef-bcf2-4ceb-afff-4642ed92f12e'
SIZE_NOT_DETECTED_ERROR
public
mixed
SIZE_NOT_DETECTED_ERROR
= '6d55c3f4-e58e-4fe3-91ee-74b492199956'
SQUARE_NOT_ALLOWED_ERROR
public
mixed
SQUARE_NOT_ALLOWED_ERROR
= '5d41425b-facb-47f7-a55a-de9fbe45cb46'
TOO_FEW_PIXEL_ERROR
public
mixed
TOO_FEW_PIXEL_ERROR
= '1b06b97d-ae48-474e-978f-038a74854c43'
TOO_HIGH_ERROR
public
mixed
TOO_HIGH_ERROR
= '7efae81c-4877-47ba-aa65-d01ccb0d4645'
TOO_LARGE_ERROR
public
mixed
TOO_LARGE_ERROR
= 'df8637af-d466-48c6-a59d-e7126250a654'
TOO_LOW_ERROR
public
mixed
TOO_LOW_ERROR
= 'aef0cb6a-c07f-4894-bc08-1781420d7b4c'
TOO_MANY_PIXEL_ERROR
public
mixed
TOO_MANY_PIXEL_ERROR
= 'ee0804e8-44db-4eac-9775-be91aaf72ce1'
TOO_NARROW_ERROR
public
mixed
TOO_NARROW_ERROR
= '9afbd561-4f90-4a27-be62-1780fc43604a'
TOO_WIDE_ERROR
public
mixed
TOO_WIDE_ERROR
= '7f87163d-878f-47f5-99ba-a8eb723a1ab2'
Properties
$allowLandscape
public
mixed
$allowLandscape
= true
$allowLandscapeMessage
public
mixed
$allowLandscapeMessage
= 'The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed.'
$allowPortrait
public
mixed
$allowPortrait
= true
$allowPortraitMessage
public
mixed
$allowPortraitMessage
= 'The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.'
$allowSquare
public
mixed
$allowSquare
= true
$allowSquareMessage
public
mixed
$allowSquareMessage
= 'The image is square ({{ width }}x{{ height }}px). Square images are not allowed.'
$binaryFormat
public
mixed
$binaryFormat
$corruptedMessage
public
mixed
$corruptedMessage
= 'The image file is corrupted.'
$detectCorrupted
public
mixed
$detectCorrupted
= false
$disallowEmptyMessage
public
mixed
$disallowEmptyMessage
= 'An empty file is not allowed.'
$groups
The groups that the constraint belongs to.
public
array<string|int, string>
$groups
$maxHeight
public
mixed
$maxHeight
$maxHeightMessage
public
mixed
$maxHeightMessage
= 'The image height is too big ({{ height }}px). Allowed maximum height is {{ max_height }}px.'
$maxPixels
public
mixed
$maxPixels
$maxPixelsMessage
public
mixed
$maxPixelsMessage
= 'The image has too many pixels ({{ pixels }} pixels). Maximum amount expected is {{ max_pixels }} pixels.'
$maxRatio
public
mixed
$maxRatio
$maxRatioMessage
public
mixed
$maxRatioMessage
= 'The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}.'
$maxSize
public
int
$maxSize
$maxSizeMessage
public
mixed
$maxSizeMessage
= 'The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}.'
$maxWidth
public
mixed
$maxWidth
$maxWidthMessage
public
mixed
$maxWidthMessage
= 'The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px.'
$mimeTypes
public
mixed
$mimeTypes
= 'image/*'
$mimeTypesMessage
public
mixed
$mimeTypesMessage
= 'This file is not a valid image.'
$minHeight
public
mixed
$minHeight
$minHeightMessage
public
mixed
$minHeightMessage
= 'The image height is too small ({{ height }}px). Minimum height expected is {{ min_height }}px.'
$minPixels
public
mixed
$minPixels
$minPixelsMessage
public
mixed
$minPixelsMessage
= 'The image has too few pixels ({{ pixels }} pixels). Minimum amount expected is {{ min_pixels }} pixels.'
$minRatio
public
mixed
$minRatio
$minRatioMessage
public
mixed
$minRatioMessage
= 'The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}.'
$minWidth
public
mixed
$minWidth
$minWidthMessage
public
mixed
$minWidthMessage
= 'The image width is too small ({{ width }}px). Minimum width expected is {{ min_width }}px.'
$notFoundMessage
public
mixed
$notFoundMessage
= 'The file could not be found.'
$notReadableMessage
public
mixed
$notReadableMessage
= 'The file is not readable.'
$payload
Domain-specific data attached to a constraint.
public
mixed
$payload
$sizeNotDetectedMessage
public
mixed
$sizeNotDetectedMessage
= 'The size of the image could not be detected.'
$uploadCantWriteErrorMessage
public
mixed
$uploadCantWriteErrorMessage
= 'Cannot write temporary file to disk.'
$uploadErrorMessage
public
mixed
$uploadErrorMessage
= 'The file could not be uploaded.'
$uploadExtensionErrorMessage
public
mixed
$uploadExtensionErrorMessage
= 'A PHP extension caused the upload to fail.'
$uploadFormSizeErrorMessage
public
mixed
$uploadFormSizeErrorMessage
= 'The file is too large.'
$uploadIniSizeErrorMessage
public
mixed
$uploadIniSizeErrorMessage
= 'The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}.'
$uploadNoFileErrorMessage
public
mixed
$uploadNoFileErrorMessage
= 'No file was uploaded.'
$uploadNoTmpDirErrorMessage
public
mixed
$uploadNoTmpDirErrorMessage
= 'No temporary folder was configured in php.ini.'
$uploadPartialErrorMessage
public
mixed
$uploadPartialErrorMessage
= 'The file was only partially uploaded.'
$errorNames
Maps error codes to the names of their constants.
protected
static mixed
$errorNames
= [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', self::SIZE_NOT_DETECTED_ERROR => 'SIZE_NOT_DETECTED_ERROR', self::TOO_WIDE_ERROR => 'TOO_WIDE_ERROR', self::TOO_NARROW_ERROR => 'TOO_NARROW_ERROR', self::TOO_HIGH_ERROR => 'TOO_HIGH_ERROR', self::TOO_LOW_ERROR => 'TOO_LOW_ERROR', self::TOO_FEW_PIXEL_ERROR => 'TOO_FEW_PIXEL_ERROR', self::TOO_MANY_PIXEL_ERROR => 'TOO_MANY_PIXEL_ERROR', self::RATIO_TOO_BIG_ERROR => 'RATIO_TOO_BIG_ERROR', self::RATIO_TOO_SMALL_ERROR => 'RATIO_TOO_SMALL_ERROR', self::SQUARE_NOT_ALLOWED_ERROR => 'SQUARE_NOT_ALLOWED_ERROR', self::LANDSCAPE_NOT_ALLOWED_ERROR => 'LANDSCAPE_NOT_ALLOWED_ERROR', self::PORTRAIT_NOT_ALLOWED_ERROR => 'PORTRAIT_NOT_ALLOWED_ERROR', self::CORRUPTED_IMAGE_ERROR => 'CORRUPTED_IMAGE_ERROR']
$maxSize
protected
mixed
$maxSize
Methods
__construct()
Initializes the constraint with options.
public
__construct([mixed $options = null ]) : mixed
You should pass an associative array. The keys should be the names of existing properties in this class. The values should be the value for these properties.
Alternatively you can override the method getDefaultOption() to return the name of an existing property. If no associative array is passed, this property is set instead.
You can force that certain options are set by overriding getRequiredOptions() to return the names of these options. If any option is not set here, an exception is thrown.
Parameters
- $options : mixed = null
-
The options (as associative array) or the value for the default option (any other type)
Tags
Return values
mixed —__get()
public
__get(mixed $option) : mixed
Parameters
- $option : mixed
Return values
mixed —__isset()
public
__isset(string $option) : bool
Parameters
- $option : string
-
The option name
Return values
bool —__set()
Sets the value of a lazily initialized option.
public
__set(string $option, mixed $value) : mixed
Corresponding properties are added to the object on first access. Hence this method will be called at most once per constraint instance and option name.
Parameters
- $option : string
-
The option name
- $value : mixed
-
The value to set
Tags
Return values
mixed —addImplicitGroupName()
Adds the given group if this constraint is in the Default group.
public
addImplicitGroupName(string $group) : mixed
Parameters
- $group : string
Return values
mixed —getDefaultOption()
Returns the name of the default option.
public
getDefaultOption() : string|null
Override this method to define a default option.
Tags
Return values
string|null —getErrorName()
Returns the name of the given error code.
public
static getErrorName(string $errorCode) : string
Parameters
- $errorCode : string
-
The error code
Tags
Return values
string —The name of the error code
getRequiredOptions()
Returns the name of the required options.
public
getRequiredOptions() : array<string|int, string>
Override this method if you want to define required options.
Tags
Return values
array<string|int, string> —getTargets()
Returns whether the constraint can be put onto classes, properties or both.
public
getTargets() : string|array<string|int, string>
This method should return one or more of the constants Constraint::CLASS_CONSTRAINT and Constraint::PROPERTY_CONSTRAINT.
Return values
string|array<string|int, string> —One or more constant values
validatedBy()
Returns the name of the class that validates this constraint.
public
validatedBy() : string
By default, this is the fully qualified name of the constraint class suffixed with "Validator". You can override this method to change that behavior.
Return values
string —normalizeBinaryFormat()
private
normalizeBinaryFormat(mixed $maxSize) : mixed
Parameters
- $maxSize : mixed