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()

Create an empty instance (without any active constraints)

fromArray(array $array)

No description

withAssetSourceConstraint(array $allowedAssetSourceIdentifiers)

No description

withMediaTypeConstraint(array $allowedMediaType)

No description

bool
hasAssetSourceConstraint()

No description

array
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

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").

Details

static AssetConstraints create()

Create an empty instance (without any active constraints)

Return Value

AssetConstraints

static AssetConstraints fromArray(array $array)

No description

Parameters

array $array

Keys: "assetSources", "mediaTypes"

Return Value

AssetConstraints

AssetConstraints withAssetSourceConstraint(array $allowedAssetSourceIdentifiers)

No description

Parameters

array $allowedAssetSourceIdentifiers

Return Value

AssetConstraints

AssetConstraints withoutAssetSourceConstraint()

No description

Return Value

AssetConstraints

AssetConstraints withMediaTypeConstraint(array $allowedMediaType)

No description

Parameters

array $allowedMediaType

Return Value

AssetConstraints

AssetConstraints withoutAssetTypeConstraint()

No description

Return Value

AssetConstraints

bool hasAssetSourceConstraint()

No description

Return Value

bool

array getAllowedAssetSourceIdentifiers()

No description

Return Value

array

bool hasMediaTypeConstraint()

No description

Return Value

bool

array getAllowedMediaTypes()

No description

Return Value

array

string getMediaTypeAcceptAttribute()

Returns the allowed media types as a string that can be used for "accept" attributes in file upload HTML elements

Return Value

string

comma separated list of allowed media types or an empty string if no media type constraints are active

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

Parameters

array $assetSources

Return Value

array

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

Parameters

string|null $assetSourceIdentifier

Return Value

string|null

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

Parameters

string $assetType

Return Value

AssetTypeFilter

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

Return Value

array