\StaticSiteFileTransformer
URL transformer specific to SilverStripe's `File` class for use with the module's import content feature. It will re-create all available data of the scraped file into SilverStripe's database and re-create a copy of the file itself on the filesystem.
If enabled in the CMS UI, links to imported images and documents in imported page-content will also be automatically
re-written.
- Author: Sam Minee <sam@silverstripe.com>
Synopsis
class StaticSiteFileTransformer
extends StaticSiteDataTypeTransformer
{
- // members
- private static number $sleep_multiplier = 10;
- // Inherited members from StaticSiteDataTypeTransformer
- public StaticSiteUtils $utils;
- public StaticSiteMimeProcessor $mimeProcessor;
- public number $parentId;
- // methods
- public void transform()
- public boolean write()
- public mixed buildFileProperties()
- public string getDirHierarchy()
- public string versionFile()
- // Inherited methods from StaticSiteDataTypeTransformer
- public void __construct()
- public null getContentFieldsAndSelectors()
- protected boolean duplicationStrategy()
- public number getCurrentImportID()
- public array getSSExtensions()
- public void setParentId()
- public number getParentId()
Hierarchy
Extends
Tasks
Line | Task |
---|---|
16+ | write unit-test for unwritable assets dir. |
206 | add another filter expression as per \FileNameFilter to module _config instead of using str_replace() here. |
Members
private
- $sleep_multiplier
—
number
Default value to pass to usleep() to reduce load on the remote server
public
- $mimeProcessor — StaticSiteMimeProcessor
- $parentId
—
number
The parent ID of an imported object - $utils
—
StaticSiteUtils
Holds the StaticSiteUtils object on construct
Methods
public
- buildFileProperties() — Build the properties required for a safely saved SilverStripe asset.
- getDirHierarchy() — Determine the correct parent directory hierarchy from the imported file's remote-path, to be located under the main SilverStripe 'assets' directory.
- transform() — Generic function called by \ExternalContentImporter
- versionFile() — Borrows logic from Upload::load() to ensure duplicated files get renamed correctly. This therefore allows multiple versions of the same physical image on the filesystem.
- write() — Write the file to the DB and Filesystem, skipping \Upload.
Inherited from StaticSiteDataTypeTransformer
protected
- duplicationStrategy() — Process incoming content according to CMS user-inputted duplication strategy.
public
- getContentFieldsAndSelectors() — Get content from remote datasource (e.g. a File, Image or page-text).
- getCurrentImportID() — Get current import ID. If none can be found, start one and return that.
- getParentId() — Gets the parent ID for an imported object.
- getSSExtensions() — Build an array of file extensions. Utilised in buildFileProperties() to check incoming file-extensions are valid against those found on {@link File}.
- setParentId() — Sets the parent ID for an imported object.