Version: current

# Class FilesystemPublisher

Usage: SS_Object::add_extension("SiteTree", "FilesystemPublisher('static-folder', 'html')");

Usage: To work with Subsite module you need to:

- Add FilesystemPublisher::$domain_based_caching = true; in mysite/_config.php
- Added main site host mapping in subsites/host-map.php after everytime a new subsite is created or modified

You may also have a method $page->pagesAffectedByUnpublishing() to return other URLS that should be de-cached if $page is unpublished.

  Extension
  DataObjectDecorator
  StaticPublisher
  FilesystemPublisher

### Direct known subclasses

`RsyncMultiHostPublisher`

Package: cms\publishers
See: http://doc.silverstripe.com/doku.php?id=staticpublisher
Located at cms/code/staticpublisher/FilesystemPublisher.php

## Methods summary

`public static` | # `set_static_base_url( mixed $url )` Set a different base URL for the static copy of the site. This can be useful if you are running the CMS on a different domain from the website. Set a different base URL for the static copy of the site. This can be useful if you are running the CMS on a different domain from the website.
`public` | # `__construct( mixed $destFolder, mixed $fileExtension = null )` #### Parameters $destFolder $destFolder The folder to save the cached site into. This needs to be set in sapphire/static-main.php as well through the $cacheBaseDir variable. $fileExtension $fileExtension The file extension to use, e.g 'html'. If omitted, then each page will be placed in its own directory, with the filename 'index.html'. If you set the extension to PHP, then a simple PHP script will be generated that can do appropriate cache & redirect header negotation. #### Overrides `Extension::__construct`
`public Array` | # `urlsToPaths( Array $urls )` Transforms relative or absolute URLs to their static path equivalent. This needs to be the same logic that's used to look up these paths through sapphire/static-main.php. Does not include the `FilesystemPublisher::$destFolder` prefix. Replaces various special characters in the resulting filename similar to `SiteTree::generateURLSegment()`. Transforms relative or absolute URLs to their static path equivalent. This needs to be the same logic that's used to look up these paths through sapphire/static-main.php. Does not include the `FilesystemPublisher::$destFolder` prefix. Replaces various special characters in the resulting filename similar to `SiteTree::generateURLSegment()`. Examples (without $domain_based_caching): - http://mysite.com/mywebroot/ => /index.html (assuming your webroot is in a subfolder) - http://mysite.com/about-us => /about-us.html - http://mysite.com/parent/child => /parent/child.html Examples (with $domain_based_caching): - http://mysite.com/mywebroot/ => /mysite.com/index.html (assuming your webroot is in a subfolder) - http://mysite.com/about-us => /mysite.com/about-us.html - http://myothersite.com/about-us => /myothersite.com/about-us.html - http://subdomain.mysite.com/parent/child => /subdomain.mysite.com/parent/child.html #### Parameters $urls Array $urls Absolute or relative URLs #### Returns `Array` Map of original URLs to filesystem paths (relative to `FilesystemPublisher::$destFolder`).
`public` | # `unpublishPages( mixed $urls )`
`public` | # `publishPages( mixed $urls )`
`protected` | # `generatePHPCacheFile( mixed $content, mixed $age, mixed $lastModified )` Generate the templated content for a PHP script that can serve up the given piece of content with the given age and expiry Generate the templated content for a PHP script that can serve up the given piece of content with the given age and expiry
`protected` | # `generatePHPCacheRedirection( mixed $destination )` Generate the templated content for a PHP script that can serve up a 301 redirect to the given destionation Generate the templated content for a PHP script that can serve up a 301 redirect to the given destionation
`public` | # `getDestDir( )`
`public` | # `getExistingStaticCacheFiles( )` Return an array of all the existing static cache files, as a map of URL => file. Only returns cache files that will actually map to a URL, based on urlsToPaths. Return an array of all the existing static cache files, as a map of URL => file. Only returns cache files that will actually map to a URL, based on urlsToPaths.

### Methods inherited from StaticPublisher

`echo_progress()`, `externalReferencesFor()`, `onAfterPublish()`, `onAfterUnpublish()`, `onRenameLinkedAsset()`, `republish()`, `set_echo_progress()`, `set_static_publisher_theme()`, `static_publisher_theme()`

### Methods inherited from DataObjectDecorator

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

### Methods inherited from Extension

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

### Magic methods summary

## Properties summary

`protected String` | $destFolder | #
`protected String` | $fileExtension | #
`protected static String` | $static_base_url | #
`public static `Boolean`` | $domain_based_caching | # Use domain based cacheing (put cache files into a domain subfolder) This must be true if you are using this with the "subsites" module. Please note that this form of caching requires all URLs to be provided absolute (not relative to the webroot) via SiteTree->AbsoluteLink(). Use domain based cacheing (put cache files into a domain subfolder) This must be true if you are using this with the "subsites" module. Please note that this form of caching requires all URLs to be provided absolute (not relative to the webroot) via SiteTree->AbsoluteLink().

### Properties inherited from StaticPublisher

`$disable_realtime`, `$echo_progress`, `$static_publisher_theme`

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