AssetConstraints
final class AssetConstraints (View source)
Constraints for the Assets that can't be changed by the user while navigating the Media module / endpoints (other than filters)
Constants
private PATTERN_MEDIA_TYPE |
|
Methods
Create an empty instance (without any active constraints)
No description
No description
No description
No description
No description
No description
No description
No description
No description
Returns the allowed media types as a string that can be used for "accept" attributes in file upload HTML elements
Filters the given $assetSources according to the active asset source constraints If no asset source constraints is active, the original array is returned
Verifies the given $assetSourceIdentifier against the asset source constraint: If no asset source constraint is set or the given $assetSourceIdentifier matches one of the allowedAssetSourceIdentifiers, the input is un-altered Otherwise the first allowed allowedAssetSourceIdentifier is returned
Verifies the given $assetType against the media type constraint: If no media type constraint is set or the given $assetType matches one of the allowed asset types, the input is un-altered Otherwise the first allowed asset type is returned
Returns an array with all supported asset type filter values according to the active media type constraints If no media type constraint is set, all options are returned including the special "All": ("All", "Image", "Video", ...) Otherwise only the allowed asset types are returned ("Video", "Image").
Details
static AssetConstraints
create()
Create an empty instance (without any active constraints)
static AssetConstraints
fromArray(array $array)
No description
AssetConstraints
withAssetSourceConstraint(array $allowedAssetSourceIdentifiers)
No description
AssetConstraints
withoutAssetSourceConstraint()
No description
AssetConstraints
withMediaTypeConstraint(array $allowedMediaType)
No description
AssetConstraints
withoutAssetTypeConstraint()
No description
bool
hasAssetSourceConstraint()
No description
array
getAllowedAssetSourceIdentifiers()
No description
bool
hasMediaTypeConstraint()
No description
array
getAllowedMediaTypes()
No description
string
getMediaTypeAcceptAttribute()
Returns the allowed media types as a string that can be used for "accept" attributes in file upload HTML elements
array
applyToAssetSources(array $assetSources)
Filters the given $assetSources according to the active asset source constraints If no asset source constraints is active, the original array is returned
string|null
applyToAssetSourceIdentifiers(string|null $assetSourceIdentifier)
Verifies the given $assetSourceIdentifier against the asset source constraint: If no asset source constraint is set or the given $assetSourceIdentifier matches one of the allowedAssetSourceIdentifiers, the input is un-altered Otherwise the first allowed allowedAssetSourceIdentifier is returned
AssetTypeFilter
applyToAssetTypeFilter(string $assetType = null)
Verifies the given $assetType against the media type constraint: If no media type constraint is set or the given $assetType matches one of the allowed asset types, the input is un-altered Otherwise the first allowed asset type is returned
array
getAllowedAssetTypeFilterOptions()
Returns an array with all supported asset type filter values according to the active media type constraints If no media type constraint is set, all options are returned including the special "All": ("All", "Image", "Video", ...) Otherwise only the allowed asset types are returned ("Video", "Image").
If only one asset type is allowed, an empty array is returned because a filter with only one option is useless