NetWerkstatt\FolderPerPage\Extensions\RootFolder
Adds a RootFolder to a Page for using it as default upload folder for all related stuff.
- Author: Werner Krauß
Synopsis
class RootFolder
extends DataExtension
{
- // members
- private static array $has_one = ;
- private static array $owns = ;
- private static array $ignored_classes = ;
- private static bool $create_folder_for_translations = false;
- private static string $folder_root = 'Articles';
- // methods
- public void onBeforeWrite()
- public void checkFolder()
- protected void createRootFolder()
- public void getFolderRoot()
- private mixed getOrCreateURLSegment()
- protected void updateRootFolder()
- public void onAfterWrite()
- public void onBeforeDuplicate()
- public mixed|string getRootFolderName()
Hierarchy
Extends
- SilverStripe\ORM\DataExtension
Tasks
Line | Task |
---|---|
64+ | doesn't check if page is moved to another parent |
170+ | : rethink moving subfolders as it may timeout on real large trees |
Members
private
- $create_folder_for_translations — NetWerkstatt\FolderPerPage\Extensions\bool
- $folder_root — string
- $has_one
- $ignored_classes — array
- $owns
Methods
private
- getOrCreateURLSegment() — code taken from SiteTree::onBeforeWrite()
protected
- createRootFolder() — Does the work of creating a new RootFolder, saves the relation in the extended DataObject
- updateRootFolder() — Does the work of updating the folder if the URLSegment or ParentID is changed.
public
- checkFolder() — Creates a folder for a page as a subfolder of the parent page You can exclude page types by setting $ignored_classes in config
- getFolderRoot() — Returns the folder root for the current root folder, e.g. 'Articles', if a config $folder_root is defined in the decorated class.
- getRootFolderName() — Helper function to return the name of the RootFolder for setting in @link UploadField or @link GridFieldBulkUpload By default relative to /assets/
- onAfterWrite() — check updates and rename folder if needed
- onBeforeDuplicate() — reset $RootFolderID on a duplicated page
- onBeforeWrite() — create folder and set relation