VuFind API Documentation

ConcatTrait

Trait to add asset pipeline functionality (concatenation / minification) to a HeadLink/HeadScript-style view helper.

Tags
category

VuFind

author

Demian Katz demian.katz@villanova.edu

author

Ere Maijala ere.maijala@helsinki.fi

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Wiki

Table of Contents

$concatIndex  : number
Future order of the concatenated file
$groups  : array<string|int, mixed>
Array of resource items by type, contains key as well
$usePipeline  : bool
Should we use the asset pipeline to join files together and minify them?
getType()  : string
Set the file path of the link object
toString()  : string
Render link elements as string Customized to minify and concatenate
addNonce()  : void
Add a content security policy nonce to the item
createConcatenatedFile()  : void
Create a concatenated file from the given group of files
enabledInConfig()  : bool
Check if config is enabled for this file type
filterItems()  : bool
Initialize class properties related to concatenation of resources.
getConcatenatedFilePath()  : string
Using the concatKey, return the path of the concatenated file.
getFileType()  : string
Get the folder name and file extension
getMinifiedData()  : string
Get minified data for a file
getMinifier()  : minifying
Get the minifier that can handle these file types
getResourceCacheDir()  : string
Get the path to the directory where we can cache files generated by this trait. The directory will be created if it does not already exist.
getResourceFilePath()  : string
Get the file path from the element object
isExcludedFromConcat()  : bool
Returns true if file should not be included in the compressed concat file
isMinifiable()  : bool
Check if a file is minifiable i.e. does not have a pattern that denotes it's already minified
isPipelineActive()  : bool
Can we use the asset pipeline?
outputInOrder()  : string
Process and return items in index order
setResourceFilePath()  : stdClass
Set the file path of the element object

Properties

$concatIndex

Future order of the concatenated file

protected number $concatIndex = null

$groups

Array of resource items by type, contains key as well

protected array<string|int, mixed> $groups = []

$usePipeline

Should we use the asset pipeline to join files together and minify them?

protected bool $usePipeline = false

Methods

getType()

Set the file path of the link object

public getType(stdClass $item) : string
Parameters
$item : stdClass

Link element object

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
string

toString()

Render link elements as string Customized to minify and concatenate

public toString([string|int $indent = null ]) : string
Parameters
$indent : string|int = null

Amount of whitespace or string to use for indention

Return values
string

addNonce()

Add a content security policy nonce to the item

protected addNonce(stdClass $item) : void
Parameters
$item : stdClass

Item

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
void

createConcatenatedFile()

Create a concatenated file from the given group of files

protected createConcatenatedFile(string $concatPath, array<string|int, mixed> $group) : void
Parameters
$concatPath : string

Resulting file path

$group : array<string|int, mixed>

Object containing 'key' and stdobj file 'items'

Tags
throws
Exception
Return values
void

enabledInConfig()

Check if config is enabled for this file type

protected enabledInConfig(string|bool $config) : bool
Parameters
$config : string|bool

Config for current application environment

Return values
bool

filterItems()

Initialize class properties related to concatenation of resources.

protected filterItems() : bool

All of the elements to be concatenated into groups and and those that need to remain on their own special group 'other'.

Return values
bool

True if there are items

getConcatenatedFilePath()

Using the concatKey, return the path of the concatenated file.

protected getConcatenatedFilePath(array<string|int, mixed> $group) : string

Generate if it does not yet exist.

Parameters
$group : array<string|int, mixed>

Object containing 'key' and stdobj file 'items'

Return values
string

getFileType()

Get the folder name and file extension

protected abstract getFileType() : string
Return values
string

getMinifiedData()

Get minified data for a file

protected getMinifiedData(array<string|int, mixed> $details, string $concatPath) : string
Parameters
$details : array<string|int, mixed>

File details

$concatPath : string

Target path for the resulting file (used in minifier for path mapping)

Tags
throws
Exception
Return values
string

getMinifier()

Get the minifier that can handle these file types

protected abstract getMinifier() : minifying
Return values
minifying

object like \MatthiasMullie\Minify\JS

getResourceCacheDir()

Get the path to the directory where we can cache files generated by this trait. The directory will be created if it does not already exist.

protected getResourceCacheDir() : string
Return values
string

getResourceFilePath()

Get the file path from the element object

protected abstract getResourceFilePath(stdClass $item) : string
Parameters
$item : stdClass

Element object

Return values
string

isExcludedFromConcat()

Returns true if file should not be included in the compressed concat file

protected abstract isExcludedFromConcat(stdClass $item) : bool
Parameters
$item : stdClass

Element object

Return values
bool

isMinifiable()

Check if a file is minifiable i.e. does not have a pattern that denotes it's already minified

protected isMinifiable(string $filename) : bool
Parameters
$filename : string

File name

Return values
bool

isPipelineActive()

Can we use the asset pipeline?

protected isPipelineActive() : bool
Return values
bool

outputInOrder()

Process and return items in index order

protected outputInOrder(string|int $indent) : string
Parameters
$indent : string|int

Amount of whitespace/string to use for indention

Return values
string

setResourceFilePath()

Set the file path of the element object

protected abstract setResourceFilePath(stdClass $item, string $path) : stdClass
Parameters
$item : stdClass

Element object

$path : string

New path string

Return values
stdClass

Search results