Version: current

# Class Requirements

Requirements tracker, for javascript and css.

Package: sapphire\view
Located at sapphire/core/Requirements.php

## Methods summary

`public static` | # `set_combined_files_enabled( boolean $enable )` Enable combining of css/javascript files. Enable combining of css/javascript files. #### Parameters $enable boolean $enable
`public static boolean` | # `get_combined_files_enabled( )` Checks whether combining of css/javascript files is enabled. Checks whether combining of css/javascript files is enabled. #### Returns `boolean` boolean
`public static` | # `set_combined_files_folder( string $folder )` Set the relative folder e.g. "assets" for where to store combined files Set the relative folder e.g. "assets" for where to store combined files #### Parameters $folder string $folder Path to folder
`public static` | # `set_suffix_requirements( boolean $var )` Set whether we want to suffix requirements with the time / location on to the requirements Set whether we want to suffix requirements with the time / location on to the requirements #### Parameters $var bool
`public static boolean` | # `get_suffix_requirements( )` Return whether we want to suffix requirements Return whether we want to suffix requirements #### Returns `boolean` bool
`public static` | # `backend( )`
`public static` | # `set_backend( `Requirements_Backend` $backend )` Setter method for changing the Requirements backend Setter method for changing the Requirements backend #### Parameters $backend Requirements $backend
`public static` | # `javascript( mixed $file )` Register the given javascript file as required. Register the given javascript file as required. See `Requirements_Backend::javascript()` for more info
`public static` | # `customScript( script $script, uniquenessID $uniquenessID = null )` Add the javascript code to the header of the page Add the javascript code to the header of the page See `Requirements_Backend::customScript()` for more info #### Parameters $script script The script content $uniquenessID uniquenessID Use this to ensure that pieces of code only get added once.
`public static` | # `customCSS( string $script, integer $uniquenessID = null )` Include custom CSS styling to the header of the page. Include custom CSS styling to the header of the page. See `Requirements_Backend::customCSS()` #### Parameters $script string $script CSS selectors as a string (without <style> tag enclosing selectors). $uniquenessID int $uniquenessID Group CSS by a unique ID as to avoid duplicate custom CSS in header
`public static` | # `insertHeadTags( string $html, string $uniquenessID = null )` Add the following custom code to the <head> section of the page. See `Requirements_Backend::insertHeadTags()` Add the following custom code to the <head> section of the page. See `Requirements_Backend::insertHeadTags()` #### Parameters $html string $html $uniquenessID string $uniquenessID
`public static` | # `javascriptTemplate( file $file, vars $vars, mixed $uniquenessID = null )` Load the given javascript template with the page. See `Requirements_Backend::javascriptTemplate()` Load the given javascript template with the page. See `Requirements_Backend::javascriptTemplate()` #### Parameters $file file The template file to load. $vars vars The array of variables to load. These variables are loaded via string search & replace. $uniquenessID
`public static` | # `css( mixed $file, mixed $media = null )` Register the given stylesheet file as required. See `Requirements_Backend::css()` Register the given stylesheet file as required. See `Requirements_Backend::css()` #### Parameters $file $file String Filenames should be relative to the base, eg, 'sapphire/javascript/tree/tree.css' $media $media String Comma-separated list of media-types (e.g. "screen,projector") #### See http://www.w3.org/TR/REC-CSS2/media.html
`public static` | # `themedCSS( mixed $name, mixed $media = null )` Register the given "themeable stylesheet" as required. See `Requirements_Backend::themedCSS()` Register the given "themeable stylesheet" as required. See `Requirements_Backend::themedCSS()` #### Parameters $name $name String The identifier of the file. For example, css/MyFile.css would have the identifier "MyFile" $media $media String Comma-separated list of media-types (e.g. "screen,projector")
`public static` | # `clear( mixed $fileOrID = null )` Clear either a single or all requirements. Caution: Clearing single rules works only with customCSS and customScript if you specified a {@uniquenessID}. Clear either a single or all requirements. Caution: Clearing single rules works only with customCSS and customScript if you specified a {@uniquenessID}. See `Requirements_Backend::clear()` #### Parameters $fileOrID $file String
`public static` | # `block( unknown_type $fileOrID )` Blocks inclusion of a specific file See `Requirements_Backend::block()` Blocks inclusion of a specific file See `Requirements_Backend::block()` #### Parameters $fileOrID unknown_type $fileOrID
`public static` | # `unblock( string $fileOrID )` Removes an item from the blocking-list. See `Requirements_Backend::unblock()` Removes an item from the blocking-list. See `Requirements_Backend::unblock()` #### Parameters $fileOrID string $fileOrID
`public static` | # `unblock_all( )` Removes all items from the blocking-list. See `Requirements_Backend::unblock_all()` Removes all items from the blocking-list. See `Requirements_Backend::unblock_all()`
`public static` | # `restore( )` Restore requirements cleared by call to Requirements::clear See `Requirements_Backend::restore()` Restore requirements cleared by call to Requirements::clear See `Requirements_Backend::restore()`
`public static string` | # `includeInHTML( string $templateFile, string $content )` Update the given HTML content with the appropriate include tags for the registered requirements. See `Requirements_Backend::includeInHTML()` for more information. Update the given HTML content with the appropriate include tags for the registered requirements. See `Requirements_Backend::includeInHTML()` for more information. #### Parameters $templateFile string $templateFilePath Absolute path for the *.ss template file $content string $content HTML content that has already been parsed from the $templateFilePath through `SSViewer`. #### Returns `string` HTML content thats augumented with the requirements before the closing <head> tag.
`public static` | # `include_in_response( `SS_HTTPResponse` $response )`
`public static` | # `add_i18n_javascript( mixed $langDir )` Add i18n files from the given javascript directory. Add i18n files from the given javascript directory. #### Parameters $langDir $langDir The javascript lang directory, relative to the site root, e.g., 'sapphire/javascript/lang' See `Requirements_Backend::add_i18n_javascript()` for more information.
`public static` | # `combine_files( string $combinedFileName, array $files )` Concatenate several css or javascript files into a single dynamically generated file. See `Requirements_Backend::combine_files()` for more info. Concatenate several css or javascript files into a single dynamically generated file. See `Requirements_Backend::combine_files()` for more info. #### Parameters $combinedFileName string $combinedFileName $files array $files
`public static array` | # `get_combine_files( )` Returns all combined files. See `Requirements_Backend::get_combine_files()` Returns all combined files. See `Requirements_Backend::get_combine_files()` #### Returns `array` array
`public static` | # `delete_combined_files( string $combinedFileName = null )` Deletes all dynamically generated combined files from the filesystem. See Requirements_Backend::delete_combine_files() Deletes all dynamically generated combined files from the filesystem. See Requirements_Backend::delete_combine_files() #### Parameters $combinedFileName string $combinedFileName If left blank, all combined files are deleted.
`public static` | # `clear_combined_files( )` Re-sets the combined files definition. See `Requirements_Backend::clear_combined_files()` Re-sets the combined files definition. See `Requirements_Backend::clear_combined_files()`
`public static` | # `process_combined_files( )` See `Requirements::combine_files()`. See `Requirements::combine_files()`.
`public static array` | # `get_custom_scripts( )` Returns all custom scripts See `Requirements_Backend::get_custom_scripts()` Returns all custom scripts See `Requirements_Backend::get_custom_scripts()` #### Returns `array` array
`public static` | # `set_write_js_to_body( boolean $var )` Set whether you want to write the JS to the body of the page or in the head section Set whether you want to write the JS to the body of the page or in the head section #### Parameters $var boolean #### See ``Requirements_Backend::set_write_js_to_body()``
`public static` | # `debug( )`

### Magic methods summary

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