SilverStripe\Assets\AssetControlExtension
This class provides the necessary business logic to ensure that any assets attached to a record are safely deleted, published, or protected during certain operations.
This class will respect the canView() of each object, and will use it to determine
whether or not public users can access attached assets. Public and live records
will have their assets promoted to the public store.
Assets which exist only on non-live stages will be protected.
Assets which are no longer referenced will be flushed via explicit delete calls
to the underlying filesystem.
Synopsis
class AssetControlExtension
extends DataExtension
{
- // members
- private static bool $keep_archived_assets = false;
- // methods
- public void onAfterDelete()
- public void onBeforeWrite()
- protected string getRecordState()
- protected void processManipulation()
- protected void addAssetsFromOtherStages()
- protected void addAssetsFromRecord()
- protected array findAssets()
- protected bool isVersioned()
- protected void deleteAll()
- protected void swapAll()
- protected void publishAll()
- protected void protectAll()
- protected AssetStore getAssetStore()
Hierarchy
Extends
- SilverStripe\ORM\DataExtension
Members
private
- $keep_archived_assets
—
SilverStripe\Assets\bool
When archiving versioned dataobjects, should assets be archived with them? If false, assets will be deleted when the dataobject is archived.
Methods
protected
- addAssetsFromOtherStages() — Checks all stages other than the current stage, and check the visibility of assets attached to those records.
- addAssetsFromRecord() — Given a record, add all assets it contains to the given manipulation.
- deleteAll() — Delete all assets in the tuple list
- findAssets() — Return a list of all tuples attached to this dataobject Note: Variants are excluded
- getAssetStore()
- getRecordState() — Check default state of this record
- isVersioned() — Determine if {@see Versioned) extension rules should be applied to this object
- processManipulation() — Given a set of asset manipulations, trigger any necessary publish, protect, or delete actions on each asset.
- protectAll() — Move all assets in the list to the protected store
- publishAll() — Move all assets in the list to the public store
- swapAll() — Move all assets in the list to the public store
public
- onAfterDelete() — Ensure that deletes records remove their underlying file assets, without affecting other staged records.
- onBeforeWrite() — Ensure that changes to records flush overwritten files, and update the visibility of other assets.