Version: current

# Class Folder

Represents a folder in the assets/ directory.

  Object
  ViewableData implements IteratorAggregate
  DataObject implements DataObjectInterface, i18nEntityProvider
  File
  Folder

Package: sapphire\filesystem
Located at sapphire/filesystem/Folder.php

## Methods summary

`public static` | # `findOrMake( mixed $folderPath )`
`public` | # `syncChildren( )` Syncronise the file database with the actual content of the assets folder Syncronise the file database with the actual content of the assets folder
`public` | # `constructChild( mixed $name )` Construct a child of this Folder with the given name. It does this without actually using the object model, as this starts messing with all the data. Rather, it does a direct database insert. Construct a child of this Folder with the given name. It does this without actually using the object model, as this starts messing with all the data. Rather, it does a direct database insert.
`public` | # `addUploadToFolder( mixed $tmpFile )` Take a file uploaded via a POST form, and save it inside this folder. Take a file uploaded via a POST form, and save it inside this folder.
`public A` | # `validate( )` Validate the current object. Validate the current object. By default, there is no validation - objects are always valid! However, you can overload this method in your DataObject sub-classes to specify custom validation. Invalid objects won't be able to be written - a warning will be thrown and no write will occur. onBeforeWrite() and onAfterWrite() won't get called either. It is expected that you call validate() in your own application to test that an object is valid before attempting a write, and respond appropriately if it isnt'. #### Returns `A` `ValidationResult` object #### Overrides `File::validate`
`public String` | # `getRelativePath( )` Returns Returns #### Returns `String` String #### Overrides `File::getRelativePath`
`public` | # `onBeforeDelete( )` Event handler called before deleting from the database. You can overload this to clean up or otherwise process data before delete this record. Don't forget to call parent::onBeforeDelete(), though! Event handler called before deleting from the database. You can overload this to clean up or otherwise process data before delete this record. Don't forget to call parent::onBeforeDelete(), though! #### Overrides `File::onBeforeDelete`
`public` | # `deleteDatabaseOnly( )` Delete the database record (recursively for folders) without touching the filesystem Delete the database record (recursively for folders) without touching the filesystem #### Overrides `File::deleteDatabaseOnly`
`public` | # `myChildren( )`
`public` | # `hasChildren( )` Returns true if this folder has children Returns true if this folder has children
`public` | # `hasChildFolders( )` Returns true if this folder has children Returns true if this folder has children
`public` | # `autosetFilename( )` Overload autosetFilename() to call autosetFilename() on all the children, too Overload autosetFilename() to call autosetFilename() on all the children, too #### Overrides `File::autosetFilename`
`protected` | # `resetFilename( mixed $renamePhysicalFile = true )` Overload resetFilename() to call resetFilename() on all the children, too. Pass renamePhysicalFile = false, since the folder renaming will have taken care of this Overload resetFilename() to call resetFilename() on all the children, too. Pass renamePhysicalFile = false, since the folder renaming will have taken care of this #### Parameters $renamePhysicalFile $renamePhysicalFile Set this to false if you don't want to rename the physical file. Used when calling resetFilename() on the children of a folder. #### Overrides `File::resetFilename`
`public` | # `cmsCleanup_parentChanged( )` This isn't a decendant of SiteTree, but needs this in case the group is "reorganised"; This isn't a decendant of SiteTree, but needs this in case the group is "reorganised";
`public `FieldSet`` | # `getCMSFields( )` Return the FieldSet used to edit this folder in the CMS. You can modify this fieldset by subclassing folder, or by creating a `DataObjectDecorator` and implemeting updateCMSFields(FieldSet $fields) on that decorator. Return the FieldSet used to edit this folder in the CMS. You can modify this fieldset by subclassing folder, or by creating a `DataObjectDecorator` and implemeting updateCMSFields(FieldSet $fields) on that decorator. #### Returns ``FieldSet`` Returns a TabSet for usage within the CMS - don't use for frontend forms. #### Overrides `DataObject::getCMSFields`
`public` | # `getUnusedFilesListFilter( )` Looks for files used in system and create where clause which contains all ID's of files. Looks for files used in system and create where clause which contains all ID's of files. #### Returns String where clause which will work as filter.
`public` | # `getUploadIframe( )` Display the upload form. Returns an iframe tag that will show admin/assets/uploadiframe. Display the upload form. Returns an iframe tag that will show admin/assets/uploadiframe.
`public` | # `ChildFolders( )` Get the children of this folder that are also folders. Get the children of this folder that are also folders.

### Methods inherited from File

`BackLinkTrackingCount()`, `CMSThumbnail()`, `DeleteLink()`, `Icon()`, `Link()`, `RelativeLink()`, `TreeTitle()`, `appCategory()`, `canCreate()`, `canDelete()`, `canEdit()`, `canView()`, `collateDescendants()`, `fieldLabels()`, `find()`, `flushCache()`, `format_size()`, `getAbsoluteSize()`, `getAbsoluteURL()`, `getExtension()`, `getFileType()`, `getFilename()`, `getFullPath()`, `getLinkedURL()`, `getSize()`, `getURL()`, `getUsageCount()`, `get_file_extension()`, `instance_get()`, `onAfterDelete()`, `onAfterUpload()`, `onBeforeWrite()`, `setField()`, `setFilename()`, `setName()`, `setParentID()`, `updateLinks()`, `uploadMetadataFields()`

### Methods inherited from DataObject

`Aggregate()`, `RelationshipAggregate()`, `__construct()`, `baseTable()`, `belongs_to()`, `buildDataObjectSet()`, `buildSQL()`, `can()`, `castedUpdate()`, `composite_fields()`, `context_obj()`, `customDatabaseFields()`, `custom_database_fields()`, `data()`, `databaseFields()`, `databaseIndexes()`, `database_extensions()`, `database_fields()`, `db()`, `dbObject()`, `debug()`, `defaultSearchFilters()`, `defineMethods()`, `delete()`, `delete_by_id()`, `destroy()`, `disableCMSFieldsExtensions()`, `disable_subclass_access()`, `duplicate()`, `enableCMSFieldsExtensions()`, `enable_subclass_access()`, `exists()`, `extendedSQL()`, `fieldLabel()`, `flush_and_destroy_cache()`, `forceChange()`, `get()`, `getAllFields()`, `getCMSActions()`, `getChangedFields()`, `getClassAncestry()`, `getComponent()`, `getComponents()`, `getComponentsQuery()`, `getDefaultSearchContext()`, `getField()`, `getFrontEndFields()`, `getManyManyComponents()`, `getManyManyComponentsQuery()`, `getManyManyFilter()`, `getManyManyJoin()`, `getRemoteJoinField()`, `getReverseAssociation()`, `getTitle()`, `get_by_id()`, `get_one()`, `get_validation_enabled()`, `hasDatabaseField()`, `hasField()`, `hasOwnTableDatabaseField()`, `hasValue()`, `has_many()`, `has_one()`, `has_own_table()`, `i18n_plural_name()`, `i18n_singular_name()`, `inheritedDatabaseFields()`, `instance_get_one()`, `isChanged()`, `isEmpty()`, `isInDB()`, `is_composite_field()`, `many_many()`, `many_many_extraFields()`, `merge()`, `newClassInstance()`, `onAfterWrite()`, `plural_name()`, `populateDefaults()`, `provideI18nEntities()`, `relObject()`, `requireDefaultRecords()`, `requireTable()`, `reset()`, `scaffoldFormFields()`, `scaffoldSearchFields()`, `searchableFields()`, `setCastedField()`, `setClassName()`, `setComponent()`, `set_context_obj()`, `set_validation_enabled()`, `singular_name()`, `summaryFields()`, `toMap()`, `update()`, `write()`, `writeComponents()`, `writeWithoutVersion()`

### Methods inherited from ViewableData

`ATT_val()`, `BaseHref()`, `CSSClasses()`, `ColumnBreak()`, `ColumnCalc()`, `ColumnNumber()`, `ColumnPad()`, `ColumnPos()`, `CurrentMember()`, `CurrentPage()`, `Debug()`, `Even()`, `EvenOdd()`, `First()`, `FirstLast()`, `HasPerm()`, `IsAjax()`, `JS_val()`, `Last()`, `Me()`, `Middle()`, `MiddleString()`, `Modulus()`, `MultipleOf()`, `Odd()`, `Pos()`, `RAW_val()`, `SQL_val()`, `ThemeDir()`, `ThemeName()`, `Top()`, `TotalItems()`, `XML_val()`, `__get()`, `__isset()`, `__set()`, `buildCastingCache()`, `cachedCall()`, `castingClass()`, `castingHelper()`, `castingHelperPair()`, `castingObjectCreator()`, `castingObjectCreatorPair()`, `customise()`, `escapeTypeForField()`, `getIterator()`, `getSecurityID()`, `getXMLValues()`, `i18nLocale()`, `iteratorProperties()`, `obj()`, `renderWith()`, `setCustomisedObj()`

### Methods inherited from Object

`__call()`, `__toString()`, `__wakeup()`, `addMethodsFrom()`, `addStaticVars()`, `addWrapperMethod()`, `add_extension()`, `add_static_var()`, `allMethodNames()`, `cacheToFile()`, `cacheToFileWithArgs()`, `clearCache()`, `combined_static()`, `create()`, `createMethod()`, `create_from_string()`, `extInstance()`, `extend()`, `getCustomClass()`, `getExtensionInstance()`, `getExtensionInstances()`, `get_extensions()`, `get_static()`, `hasExtension()`, `hasMethod()`, `has_extension()`, `invokeWithExtensions()`, `is_a()`, `loadCache()`, `parentClass()`, `parse_class_spec()`, `remove_extension()`, `sanitiseCachename()`, `saveCache()`, `set_stat()`, `set_static()`, `set_uninherited()`, `stat()`, `strong_create()`, `uninherited()`, `uninherited_static()`, `useCustomClass()`

### Magic methods summary

## Properties summary

`public static string` | $default_sort | # The default sort expression. This will be inserted in the ORDER BY clause of a SQL query if no other sort expression is provided. The default sort expression. This will be inserted in the ORDER BY clause of a SQL query if no other sort expression is provided.

### Properties inherited from File

`$allowed_extensions`, `$apply_restrictions_to_admin`, `$belongs_many_many`, `$cache_file_fields`, `$db`, `$defaults`, `$extensions`, `$has_many`, `$has_one`, `$indexes`, `$many_many`, `$plural_name`, `$singular_name`

### Properties inherited from DataObject

`$allowed_actions`, `$ancestry`, `$api_access`, `$belongs_to`, `$brokenOnDelete`, `$brokenOnWrite`, `$cache_get_one`, `$cache_has_own_table`, `$cache_has_own_table_field`, `$casting`, `$componentCache`, `$components`, `$create_table_options`, `$default_records`, `$destroyed`, `$field_labels`, `$many_many_extraFields`, `$original`, `$record`, `$searchable_fields`, `$summary_fields`

### Properties inherited from ViewableData

`$customisedObject`, `$default_cast`, `$failover`, `$iteratorPos`, `$iteratorTotalItems`

### Properties inherited from Object

`$class`, `$extension_instances`

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -