abstract class AbstractAssetsPackage

Class to manage assets paths

The class is based on three paths:

  • base_dir: the package root directory (must be the directory containing the composer.json file)
  • assets_dir: the package asssets directory related to base_dir
  • document_root: the path in the filesystem of the web assets root directory ; this is used to build all related assets paths to use in HTTP.

For these three paths, their defaults values are defined on a default package structure:

package_name/
|----------- src/
|----------- www/

$loader->base_dir = realpath(package_name)
$loader->assets_dir = www
$loader->document_root = www or the server DOCUMENT_ROOT

NOTE - These paths are stored in the object without the trailing slash.

Methods

__construct(string $root_dir = null, string $assets_dir = null, string $vendor_dir = null, string $assets_vendor_dir = null)

No description

setRootDirectory(string $path)

Set the project root directory absolute path

string
getRootDirectory()

Get the project root directory absolute path

setAssetsDirectory(string $path)

Set the project's assets directory, relative to $this->_root_dir

string
getAssetsDirectory()

Get the project's assets directory, relative to $this->_root_dir

setVendorDirectory(string $path)

Set the project's vendor directory, relative to $this->_root_dir

string
getVendorDirectory()

Get the project's vendor directory, relative to $this->_root_dir

setAssetsVendorDirectory(string $path)

Set the project's assets vendor directory, relative to $this->_assets_dir

string
getAssetsVendorDirectory()

Get the project's vendor directory, relative to $this->_root_dir

string
getFullPath(string $path, string $type = null, bool $out = false)

Get the absolute path in the package

string
getAssetsRealPath()

Get the assets full path

string
getVendorRealPath()

Get the assets full path

string
getAssetsVendorRealPath()

Get the assets vendor full path

Details

at line 86
__construct(string $root_dir = null, string $assets_dir = null, string $vendor_dir = null, string $assets_vendor_dir = null)

Parameters

string $root_dir
string $assets_dir
string $vendor_dir
string $assets_vendor_dir

Exceptions

Exception : any caught exception

at line 112
AbstractAssetsPackage setRootDirectory(string $path)

Set the project root directory absolute path

Parameters

string $path

Return Value

AbstractAssetsPackage

Exceptions

InvalidArgumentException if the path doesn't exist

at line 129
string getRootDirectory()

Get the project root directory absolute path

Return Value

string

at line 141
AbstractAssetsPackage setAssetsDirectory(string $path)

Set the project's assets directory, relative to $this->_root_dir

Parameters

string $path

Return Value

AbstractAssetsPackage

Exceptions

InvalidArgumentException if the path doesn't exist

at line 159
string getAssetsDirectory()

Get the project's assets directory, relative to $this->_root_dir

Return Value

string

at line 171
AbstractAssetsPackage setVendorDirectory(string $path)

Set the project's vendor directory, relative to $this->_root_dir

Parameters

string $path

Return Value

AbstractAssetsPackage

Exceptions

InvalidArgumentException if the path doesn't exist

at line 189
string getVendorDirectory()

Get the project's vendor directory, relative to $this->_root_dir

Return Value

string

at line 201
AbstractAssetsPackage setAssetsVendorDirectory(string $path)

Set the project's assets vendor directory, relative to $this->_assets_dir

Parameters

string $path

Return Value

AbstractAssetsPackage

Exceptions

InvalidArgumentException if the path doesn't exist

at line 219
string getAssetsVendorDirectory()

Get the project's vendor directory, relative to $this->_root_dir

Return Value

string

at line 236
string getFullPath(string $path, string $type = null, bool $out = false)

Get the absolute path in the package

Parameters

string $path The relative path to complete
string $type Type of the original relative path (can be asset, vendor or assets_vendor - default is null)
bool $out Must we search in assets and vendor (if false) or not (if true)

Return Value

string

at line 277
string getAssetsRealPath()

Get the assets full path

Return Value

string

at line 287
string getVendorRealPath()

Get the assets full path

Return Value

string

at line 297
string getAssetsVendorRealPath()

Get the assets vendor full path

Return Value

string