\BrickrougeDocument

An HTML document.

Summary

Methods
Properties
Constants
__construct()
add_assets()
resolve_url()
$body
$js
$css
$assets
No constants found
get_assets()
set_assets()
__unset_assets()
No protected properties found
N/A
resolve_root()
No private properties found
N/A

Properties

$body

$body : 

Type

$assets

$assets : 

array The Javascript and CSS assets used by the document.

Type

Methods

__construct()

__construct() 

Constructor.

Creates the Javascript and CSS collectors.

add_assets()

add_assets(array  $assets) 

Adds a number of assets to the document.

Parameters

array $assets

An array where CSS and JS assets are stored under the 'css' and 'js' keys respectively. Each asset is defined as a key/value pair where the key if the path to the asset and the key is its priority.

Examples

( array ( 'css' => array('brickrouge.css' => 0), 'js' => array('brickrouge.js' => 0) ) );
** File not found : $document->add_assets **

resolve_url()

resolve_url(string  $path, string  $relative = null) : string

Resolves a server path into a URL accessible from the `DOCUMENT_ROOT`.

Unless the path uses a scheme (http://, https:// or phar://) it is always considered relative to the path specified by the $relative parameter or to the DOCUMENT_ROOT.

Parameters

string $path
string $relative

Relative path that can be used to resolve the path. If the parameter is null the method tries to guess the relative path using the {@link resolve_root()} private method.

Returns

string —

The URL resolved from the path.

get_assets()

get_assets() : array

Returns the Javascript and CSS assets used by the document as an array or URLs.

Returns

array —

The assets used by the document.

set_assets()

set_assets(array  $assets) 

Sets the assets of the document.

Parameters

array $assets

An array where CSS and JS assets are stored under the 'css' and 'js' keys respectively. Each asset is defined as a key/value pair where the key if the path to the asset and the key is its priority.

Examples

= array ( 'css' => array('brickrouge.css' => 0), 'js' => array('brickrouge.js' => 0) );
** File not found : $document->assets **

__unset_assets()

__unset_assets() 

Clears JS and CSS assets.

Examples

$document->css->add('brickrouge.css'); var_dump($document->assets); // ['css' => ['brickrouge.css'], 'js' => ['brickrouge.js']] unset($document->assets); var_dump($document->assets); // ['css' => [], 'js' => []]
** File not found : $document->js->add('brickrouge.js'); **

resolve_root()

resolve_root() : string|null

Tries to locate the file where the assets was added by searching for the first file which is not the file where our class is defined.

Returns

string|null —

The path to the directory of the file or null if no file could be found.