AssetService
class AssetService (View source)
An asset service that handles for example commands on assets, retrieves information about usage of assets and rendering thumbnails.
Properties
protected ResourceManager | $resourceManager | ||
protected ThumbnailService | $thumbnailService | ||
protected UriBuilder | $uriBuilder | ||
protected ObjectManagerInterface | $objectManager | ||
protected ReflectionService | $reflectionService | ||
protected array | $usageStrategies | ||
protected PackageManager | $packageManager | ||
protected LoggerInterface | $logger | ||
protected ImageService | $imageService | ||
protected AssetVariantGenerator | $assetVariantGenerator |
Methods
Calculates the dimensions of the thumbnail to be generated and returns the thumbnail URI.
Returns all registered asset usage strategies
Replace resource on an asset. Takes variants and redirect handling into account.
Signals that a resource on an asset has been replaced
Details
RepositoryInterface
getRepository(AssetInterface $asset)
Returns the repository for an asset
array|null
getThumbnailUriAndSizeForAsset(AssetInterface $asset, ThumbnailConfiguration $configuration, ActionRequest $request = null)
Calculates the dimensions of the thumbnail to be generated and returns the thumbnail URI.
In case of Images this is a thumbnail of the image, in case of other assets an icon representation.
protected array
getUsageStrategies()
Returns all registered asset usage strategies
array
getUsageReferences(AssetInterface $asset)
Returns an array of asset usage references.
int
getUsageCount(AssetInterface $asset)
Returns the total count of times an asset is used.
bool
isInUse(AssetInterface $asset)
Returns true if the asset is used.
void
validateRemoval(AssetInterface $asset)
Validates if the asset can be removed
void
replaceAssetResource(AssetInterface $asset, PersistentResource $resource, array $options = [])
Replace resource on an asset. Takes variants and redirect handling into account.
void
emitAssetCreated(AssetInterface $asset)
Signals that an asset was added.
void
emitAssetRemoved(AssetInterface $asset)
Signals that an asset was removed.
void
emitAssetUpdated(AssetInterface $asset)
Signals that an asset was updated.
void
emitAssetResourceReplaced(AssetInterface $asset)
Signals that a resource on an asset has been replaced
Note: when an asset resource is replaced, the assetUpdated signal is sent anyway and can be used instead.