1 | <?php |
||
10 | class RootFolder extends DataExtension |
||
|
|||
11 | { |
||
12 | private static $has_one = array( |
||
13 | 'RootFolder' => 'Folder', |
||
14 | ); |
||
15 | |||
16 | /** |
||
17 | * @var array exclude this page types and class names |
||
18 | */ |
||
19 | private static $ignored_classes = array('VirtualPage', 'ErrorPage'); |
||
20 | |||
21 | /** |
||
22 | * @var bool should folders be created for translated objects? |
||
23 | */ |
||
24 | private static $create_folder_for_translations = false; |
||
25 | |||
26 | /** |
||
27 | * @var string default root for all folders; may be overwritten in config of decorated class |
||
28 | */ |
||
29 | private static $folder_root = 'Articles'; |
||
30 | |||
31 | public function onAfterWrite() |
||
37 | |||
38 | /** |
||
39 | * reset $RootFolderID on a duplicated page |
||
40 | */ |
||
41 | public function onBeforeDuplicate($originalOrClone) |
||
47 | |||
48 | /** |
||
49 | * Creates a folder for a page as a subfolder of the parent page |
||
50 | * You can exclude page types by setting $ignored_classes in config |
||
51 | * |
||
52 | * Doesn't create folders for translated pages by default. |
||
53 | * |
||
54 | * @TODO doesn't check if page is moved to another parent |
||
55 | */ |
||
56 | public function checkFolder() |
||
79 | |||
80 | /** |
||
81 | * Does the work of creating a new RootFolder, saves the relation in the extended DataObject |
||
82 | */ |
||
83 | protected function createRootFolder() |
||
108 | |||
109 | /** |
||
110 | * Does the work of updating the folder if the URLSegment or ParentID is changed. |
||
111 | * if both it does two writes... |
||
112 | * |
||
113 | * @todo: rethink moving subfolders as it may timeout on real large trees |
||
114 | */ |
||
115 | protected function updateRootFolder() |
||
132 | |||
133 | /** |
||
134 | * Returns the folder root for the current root folder, e.g. 'Articles', |
||
135 | * if a config $folder_root is defined in the decorated class. |
||
136 | * |
||
137 | * Falls back to global config |
||
138 | */ |
||
139 | public function getFolderRoot() |
||
145 | |||
146 | |||
147 | /** |
||
148 | * Helper function to return the name of the RootFolder for setting in @link UploadField or @link GridFieldBulkUpload |
||
149 | * By default relative to /assets/ |
||
150 | * |
||
151 | * @param bool $relativeToAssetsDir |
||
152 | */ |
||
153 | public function getRootFolderName($relativeToAssetsDir = true) |
||
164 | } |
||
165 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.