PHP Class Contao\Combiner

Usage: $combiner = new Combiner(); $combiner->add('css/style.css'); $combiner->add('css/fonts.scss'); $combiner->add('css/print.less'); echo $combiner->getCombinedFile();
Inheritance: extends System
Exibir arquivo Open project: contao/core-bundle Class Usage Examples

Protected Properties

Property Type Description
$arrFiles array Files
$strKey string Unique file key
$strMode string Operation mode

Public Methods

Method Description
__construct ( ) Public constructor required
add ( string $strFile, string $strVersion = null, string $strMedia = 'all' ) Add a file to the combined file
addMultiple ( array $arrFiles, string $strVersion = null, string $strMedia = 'screen' ) Add multiple files from an array
getCombinedFile ( string $strUrl = null ) : string Generate the combined file and return its path
getFileUrls ( ) : array Generates the files and returns the URLs.
hasEntries ( ) : boolean Check whether files have been added

Protected Methods

Method Description
fixPaths ( string $content, array $arrFile ) : string Fix the paths
getCombinedFileUrl ( string $strUrl = null ) : string Generate the combined file and return its path
getDebugMarkup ( ) : string Generates the debug markup.
handleCss ( string $content, array $arrFile ) : string Handle CSS files
handleScssLess ( string $content, array $arrFile ) : string Handle SCSS/LESS files

Method Details

__construct() public method

Public constructor required
public __construct ( )

add() public method

Add a file to the combined file
public add ( string $strFile, string $strVersion = null, string $strMedia = 'all' )
$strFile string The file to be added
$strVersion string An optional version number
$strMedia string The media type of the file (.css only)

addMultiple() public method

Add multiple files from an array
public addMultiple ( array $arrFiles, string $strVersion = null, string $strMedia = 'screen' )
$arrFiles array An array of files to be added
$strVersion string An optional version number
$strMedia string The media type of the file (.css only)

fixPaths() protected method

Fix the paths
protected fixPaths ( string $content, array $arrFile ) : string
$content string The file content
$arrFile array The file array
return string The modified file content

getCombinedFile() public method

Generate the combined file and return its path
public getCombinedFile ( string $strUrl = null ) : string
$strUrl string An optional URL to prepend
return string The path to the combined file

getCombinedFileUrl() protected method

Generate the combined file and return its path
protected getCombinedFileUrl ( string $strUrl = null ) : string
$strUrl string An optional URL to prepend
return string The path to the combined file

getDebugMarkup() protected method

Generates the debug markup.
protected getDebugMarkup ( ) : string
return string The debug markup

getFileUrls() public method

Generates the files and returns the URLs.
public getFileUrls ( ) : array
return array The file URLs

handleCss() protected method

Handle CSS files
protected handleCss ( string $content, array $arrFile ) : string
$content string The file content
$arrFile array The file array
return string The modified file content

handleScssLess() protected method

Handle SCSS/LESS files
protected handleScssLess ( string $content, array $arrFile ) : string
$content string The file content
$arrFile array The file array
return string The modified file content

hasEntries() public method

Check whether files have been added
public hasEntries ( ) : boolean
return boolean True if there are files

Property Details

$arrFiles protected_oe property

Files
protected array $arrFiles
return array

$strKey protected_oe property

Unique file key
protected string $strKey
return string

$strMode protected_oe property

Operation mode
protected string $strMode
return string