VuFind API Documentation

HeadScript extends HeadScript
in package
implements LoggerAwareInterface Uses ConcatTrait, RelativePathTrait, LoggerAwareTrait

Head script view helper (extended for VuFind's theme system)

Tags
category

VuFind

author

Demian Katz demian.katz@villanova.edu

license

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

link

Wiki

Interfaces, Classes, Traits and Enums

LoggerAwareInterface

Table of Contents

$concatIndex  : number
Future order of the concatenated file
$cspNonce  : string
CSP nonce
$groups  : array<string|int, mixed>
Array of resource items by type, contains key as well
$themeInfo  : ThemeInfo
Theme information service
$usePipeline  : bool
Should we use the asset pipeline to join files together and minify them?
__construct()  : mixed
Constructor
forcePrependFile()  : void
Forcibly prepend a file removing it from any existing position
getIndent()  : void
getSeparator()  : void
getType()  : string
Set the file path of the link object
getWhitespace()  : void
itemToString()  : string
Create script HTML
toString()  : string
Render link elements as string Customized to minify and concatenate
addNonce()  : void
Add a nonce to the item
createConcatenatedFile()  : void
Create a concatenated file from the given group of files
debug()  : void
Log a debug message.
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
Folder name and file extension for trait
getMinifiedData()  : string
Get minified data for a file
getMinifier()  : JS
Get the minifier that can handle these file types Required by ConcatTrait
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 script object Required by ConcatTrait
isExcludedFromConcat()  : bool
Returns true if file should not be included in the compressed concat file Required by ConcatTrait
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?
isRelativePath()  : bool
Is the provided src value a relative path? Returns true if this should be searched within the local theme, or false if it is an absolute path or full URL.
log()  : void
Send a message to the logger.
logError()  : void
Log an error message.
logWarning()  : void
Log a warning message.
outputInOrder()  : string
Process and return items in index order
setResourceFilePath()  : stdClass
Set the file path of the script object Required by ConcatTrait

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

__construct()

Constructor

public __construct(ThemeInfo $themeInfo[, string|bool $plconfig = false ][, string $nonce = '' ]) : mixed
Parameters
$themeInfo : ThemeInfo

Theme information service

$plconfig : string|bool = false

Config for current application environment

$nonce : string = ''

Nonce from nonce generator

Return values
mixed

forcePrependFile()

Forcibly prepend a file removing it from any existing position

public forcePrependFile([string $src = null ][, string $type = 'text/javascript' ][, array<string|int, mixed> $attrs = [] ]) : void
Parameters
$src : string = null

Script src

$type : string = 'text/javascript'

Script type

$attrs : array<string|int, mixed> = []

Array of script attributes

Return values
void

getIndent()

public getIndent() : void
Return values
void

getSeparator()

public getSeparator() : void
Return values
void

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

getWhitespace()

public getWhitespace(string|int $indent) : void
Parameters
$indent : string|int
Return values
void

itemToString()

Create script HTML

public itemToString(mixed $item, string $indent, string $escapeStart, string $escapeEnd) : string
Parameters
$item : mixed

Item to convert

$indent : string

String to add before the item

$escapeStart : string

Starting sequence

$escapeEnd : string

Ending sequence

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 nonce to the item

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

Item

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

debug()

Log a debug message.

protected debug(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

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()

Folder name and file extension for trait

protected 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 Required by ConcatTrait

protected getMinifier() : JS
Return values
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 script object Required by ConcatTrait

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

Script element object

Return values
string

isExcludedFromConcat()

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

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

Script 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

isRelativePath()

Is the provided src value a relative path? Returns true if this should be searched within the local theme, or false if it is an absolute path or full URL.

protected isRelativePath(string $src) : bool
Parameters
$src : string

Value to check

Return values
bool

log()

Send a message to the logger.

protected log(string $level, string $message[, array<string|int, mixed> $context = [] ][, bool $prependClass = false ]) : void
Parameters
$level : string

Log level

$message : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = false

Prepend class name to message?

Return values
void

logError()

Log an error message.

protected logError(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

logWarning()

Log a warning message.

protected logWarning(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

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 script object Required by ConcatTrait

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

Script element object

$path : string

New path string

Return values
stdClass

Search results