Requirements_Backend
class Requirements_Backend (View source)
Properties
array | $combine_files | A list of combined files registered via {@link combine_files()}. Keys are the output file names, values are lists of input files. |
|
bool | $combine_js_with_jsmin | Use the JSMin library to minify any javascript file passed to {@link combine_files()}. |
|
bool | $write_header_comment | Whether or not file headers should be written when combining files |
|
bool | $write_js_to_body | Put all JavaScript includes at the bottom of the template before the closing tag, rather than the default behaviour of placing them at the end of the tag. This means script downloads won't block other HTTP requests, which can be a performance improvement. |
Methods
Enable or disable the combination of CSS and JavaScript files
Check whether file combination is enabled.
Set the folder to save combined files in. By default they're placed in assets/_combinedfiles, however this may be an issue depending on your setup, especially for CSS files which often contain relative paths.
No description
Set whether to add caching query params to the requests for file-based requirements.
Check whether we want to suffix requirements
Set whether you want to write the JS to the body of the page rather than at the end of the head tag.
Forces the JavaScript requirements to the end of the body, right before the closing tag
Register the given JavaScript file as required.
Returns an array of all required JavaScript
Register the given JavaScript code into the list of requirements
Return all registered custom scripts
Register the given CSS styles into the list of requirements
Add the following custom HTML code to the
section of the pageInclude the content of the given JavaScript file in the list of requirements. Dollar-sign variables will be interpolated with values from $vars similar to a .ss template.
Register the given stylesheet into the list of requirements.
Get the list of registered CSS file requirements, excluding blocked files
Clear either a single or all requirements
Restore requirements cleared by call to Requirements::clear
Block inclusion of a specific file
Remove an item from the block list
Removes all items from the block list
Update the given HTML content with the appropriate include tags for the registered requirements. Needs to receive a valid HTML/XHTML template in the $content parameter, including a head and body tag.
Attach requirements inclusion to X-Include-JS and X-Include-CSS headers on the given HTTP Response
Add i18n files from the given javascript directory. SilverStripe expects that the given directory will contain a number of JavaScript files named by language: en_US.js, de_DE.js, etc.
Concatenate several css or javascript files into a single dynamically generated file. This increases performance by fewer HTTP requests.
Return all combined files; keys are the combined file names, values are lists of files being combined.
Delete all dynamically generated combined files from the filesystem
Deletes all generated combined files in the configured combined files directory, but doesn't delete the directory itself.
Clear all registered CSS and JavaScript file combinations
Do the heavy lifting involved in combining (and, in the case of JavaScript minifying) the combined files.
Registers the given themeable stylesheet as required.
Registers the given themeable javascript as required.
Output debugging information.
Details
set_combined_files_enabled($enable)
Enable or disable the combination of CSS and JavaScript files
bool
get_combined_files_enabled()
Check whether file combination is enabled.
setCombinedFilesFolder(string $folder)
Set the folder to save combined files in. By default they're placed in assets/_combinedfiles, however this may be an issue depending on your setup, especially for CSS files which often contain relative paths.
string
getCombinedFilesFolder()
set_suffix_requirements($var)
Set whether to add caching query params to the requests for file-based requirements.
Eg: themes/myTheme/js/main.js?m=123456789. The parameter is a timestamp generated by filemtime. This has the benefit of allowing the browser to cache the URL infinitely, while automatically busting this cache every time the file is changed.
bool
get_suffix_requirements()
Check whether we want to suffix requirements
set_write_js_to_body($var)
Set whether you want to write the JS to the body of the page rather than at the end of the head tag.
set_force_js_to_bottom($var)
Forces the JavaScript requirements to the end of the body, right before the closing tag
javascript(string $file)
Register the given JavaScript file as required.
array
get_javascript()
Returns an array of all required JavaScript
customScript(string $script, string|int $uniquenessID = null)
Register the given JavaScript code into the list of requirements