SALT main class

package salt

 Methods

Add a folder to the class autoload mecanism.

addClassFolder(string $folder, string $namespace = NULL, string $pattern = '.class.php', array<mixed,string> $excludes = NULL
Static

Parameters

$folder

string

root folder that contain classes

$namespace

string

(Optional, NULL) Namespace to use for register classes

$pattern

string

(Optional, .class.php) Suffix of files that contains classes

$excludes

array<mixed,string>

(Optional, NULL) List of folders or files to exclude. Can be a part of a folder/file

Compute a folder from a path and a relative path

computePath(string $origin, string $relative, string $separator = '/') : string
Static

Parameters

$origin

string

a folder, with or without trailing directory $separator

$relative

string

relative folder, with / separator

$separator

string

folder separator for $origin, default to /

Returns

stringthe resolved path, always end with $separator

Return the relative path between two folders.

computeRelativePath(string $from, string $dest, integer $destIgnoreLevel = 0) : string
Static

Parameters can be provided with a file or ends with / (or )
All characters after the last / (or ) is ignored

Parameters

$from

string

Origin path

$dest

string

Destination path

$destIgnoreLevel

integer

(Optional, 0) Ignore some folders at the end of the destination path

Exceptions

\salt\SaltException If the origin and destination paths are not both relative or absolute path

Returns

stringRelative path for go to $dest from $from. Return always ends with /

Load SALT configuration

config(array<mixed,string> $locales = NULL
Static

Parameters

$locales

array<mixed,string>

Locales to try to initialize. First available locale is used.

Return a list of registered classes in provided path

getClassesByPath(string $path) : array<mixed,string>
Static

Parameters

$path

string

the path to find classes

Returns

array<mixed,string>classes as (className => path)

Load a class

loadClass(string $className) : boolean
Static

Parameters

$className

string

Class name with namespace to load

Returns

booleanTRUE if class found, FALSE otherwise

Retrieve relative path from executed PHP script to method caller

relativePath(integer $destIgnoreLevel = 0) : string
Static

Parameters

$destIgnoreLevel

integer

(Optionnel, 0) Ignore some folders at the end of the method caller

Returns

stringRelative path between executed PHP script and method caller

Return absolute SALT path

saltPath() : string
Static

Returns

stringabsolute SALT path

Retrieve relative path from request URI to method caller

webRelativePath(integer $destIgnoreLevel = 0) : string
Static

Parameters

$destIgnoreLevel

integer

(Optionnel, 0) Ignore some folders at the end of the method caller

Returns

stringRelative path between requested URI and method caller (usefull for URI rewrite)

Deep walk in a folder for find files that contains classes

findAllClasses(string $folder, string $namespace = NULL, string $pattern = '.class.php', array<mixed,string> $excludes = NULL) : array<mixed,string>
Static

Parameters

$folder

string

Folder to inspect

$namespace

string

(Optional, NULL) Namespace to use

$pattern

string

(Optional, .class.php) Suffix to use for filter files

$excludes

array<mixed,string>

(Optional, NULL) List of folders or files to exclude. Can be a part of a folder/file

Returns

array<mixed,string>List or found files as ( Namespace\ClassName => FilePath )

Return caller file

firstCallerFile(integer $ignoreCallers = 0) : array<mixed,string>
Static
see

Parameters

$ignoreCallers

integer

number of first callers to ignore

Returns

array<mixed,string>associative array of a backtrace with keys : file, line

Initialize I18n instance

initI18n(array<mixed,string> $locales) 
Static

Parameters

$locales

array<mixed,string>

Locales to try to initialize. First available locale is used.

 Properties

 

all classes that can be loaded by our autoload : namespace\class => /full/class/path

$ALL_CLASSES : array<mixed,string>

Default

array()
Static