Version: current

# Class AssociatedFolderDecorator

Decorate a data object so that it has an associated folder on the file system that lives and dies with this object. You can access this associated folder from the object via myObj->AssociatedFolder() Extend a DataObject class by calling DataObject::add_extension('MyDataObject', 'AssociatedFolderDecorator');

  Extension
  DataObjectDecorator
  SiteTreeDecorator
  AssociatedFolderDecorator

Located at webylon/code/AssociatedFolderDecorator.php

## Methods summary

`public array` | # `extraStatics( )` Define extra database fields Define extra database fields Return a map where the keys are db, has_one, etc, and the values are additional fields/relations to be defined. #### Returns `array` Returns a map where the keys are db, has_one, etc, and the values are additional fields/relations to be defined. #### Overrides `DataObjectDecorator::extraStatics`
`public static` | # `setDefaultRootFolderName( string $folderName )` Set the folder name to use if the decorated object's parent has no associated folder of its own. Set the folder name to use if the decorated object's parent has no associated folder of its own. #### Parameters $folderName string $folderName
`public static string` | # `getDefaultRootFolderName( )` Get the folder name to use if the decorated object's parent has no associated folder of its own. Get the folder name to use if the decorated object's parent has no associated folder of its own. #### Returns `string` string
`public` | # `onAfterWrite( )` Do stuff before the decorated object is written. In this case create the associated folder if it does not already exist. Do stuff before the decorated object is written. In this case create the associated folder if it does not already exist. #### Overrides `DataObjectDecorator::onAfterWrite`
`public` | # `onBeforeDuplicate( mixed $page )`
`public` | # `getHash( )`
`public` | # `getAssociatedFolderName( )`
`public` | # `getAssociatedFolderTitle( )`
`public` | # `getAssociatedFolderParentName( )`
`public` | # `getAssociatedFolderParentTitle( )`
`public `Folder`` | # `createAssociatedFolder( )` Create the associated folder Create the associated folder #### Returns ``Folder`` Folder
`public `Folder`` | # `getAssociatedFolder( )` Return the associated folder Return the associated folder #### Returns ``Folder`` Folder
`public` | # `onAfterDelete( )` #### Overrides `DataObjectDecorator::onAfterDelete`

### Methods inherited from SiteTreeDecorator

`canAddChildren()`, `canPublish()`, `onAfterPublish()`, `onAfterUnpublish()`, `onBeforePublish()`, `onBeforeUnpublish()`

### Methods inherited from DataObjectDecorator

`augmentDatabase()`, `augmentSQL()`, `augmentWrite()`, `can()`, `canCreate()`, `canDelete()`, `canEdit()`, `flushCache()`, `load_extra_statics()`, `onBeforeDelete()`, `onBeforeWrite()`, `populateDefaults()`, `requireDefaultRecords()`, `updateCMSActions()`, `updateCMSFields()`, `updateFieldLabels()`, `updateFrontEndFields()`, `updateSummaryFields()`

### Methods inherited from Extension

`__construct()`, `clearOwner()`, `getOwner()`, `get_classname_without_arguments()`, `setOwner()`

### Magic methods summary

## Properties summary

`public static boolean` | $createFolders | # Флаг - создавать ли автоматически прикрепленную папку. По умолчанию true. Можно использовать при импорте - когда не нужно создавать папки сразу. Флаг - создавать ли автоматически прикрепленную папку. По умолчанию true. Можно использовать при импорте - когда не нужно создавать папки сразу.
`public static string` | $hash_mode | # Способ формирования имен hash папок Возможные значения: ceil100 - делением id страницы на 100 (по 100 страниц в одной hash папке) - удобно если id меньше 25 000, допустимо до 100 0000 rem256 - остаток от деления id страницы на 256 (256 hash папок, равномерное распределение) - удобно при кол-ве страниц более 10 000 rem_1000 - остаток от деления на 1000 (1000 hash папок, равномерное распределение) - удобно при кол-ве страниц более 200 000 NB: если есть регулярный импорт товаров с созданием AssociatedFolder рекомендуется менять hash_mode на rem256 или rem_1000 Способ формирования имен hash папок Возможные значения: ceil100 - делением id страницы на 100 (по 100 страниц в одной hash папке) - удобно если id меньше 25 000, допустимо до 100 0000 rem256 - остаток от деления id страницы на 256 (256 hash папок, равномерное распределение) - удобно при кол-ве страниц более 10 000 rem_1000 - остаток от деления на 1000 (1000 hash папок, равномерное распределение) - удобно при кол-ве страниц более 200 000 NB: если есть регулярный импорт товаров с созданием AssociatedFolder рекомендуется менять hash_mode на rem256 или rem_1000
`protected static string` | $defaultRootFolderName | # The folder name to use if the decorated object's parent has no associated folder of its own. The folder name to use if the decorated object's parent has no associated folder of its own.

### Properties inherited from DataObjectDecorator

`$decoratable_statics`

### Properties inherited from Extension

`$allowed_actions`, `$class`, `$owner`, `$ownerBaseClass`

[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. -