api.md

February 17, 2019 · View on GitHub

Table of contents


Class: \UserFrosting\UniformResourceLocator\ResourceLocation

ResourceLocation Class The representation of a location

VisibilityFunction
public__construct(string name</strong>,<em>string/null</em><strong>name</strong>, <em>string/null</em> <strong>path=null) : void
Constructor
publicgetName() : string
publicgetPath() : string
publicsetName(string $name) : \UserFrosting\UniformResourceLocator\static
publicsetPath(string $path=null) : \UserFrosting\UniformResourceLocator\static

This class implements \UserFrosting\UniformResourceLocator\ResourceLocationInterface


Interface: \UserFrosting\UniformResourceLocator\ResourceLocationInterface

ResourceLocationInterface Interface

VisibilityFunction
publicgetName() : string
publicgetPath() : string
publicsetName(string $name) : \UserFrosting\UniformResourceLocator\static
publicsetPath(string $path=null) : \UserFrosting\UniformResourceLocator\static

Class: \UserFrosting\UniformResourceLocator\ResourceStream

ResourceStream Class The representation of a stream

VisibilityFunction
public__construct(string scheme</strong>,<em>string</em><strong>scheme</strong>, <em>string</em> <strong>prefix='', string path=null</strong>,<em>bool</em><strong>path=null</strong>, <em>bool</em> <strong>shared=false) : void
Constructor
publicgetPath() : string
publicgetPrefix() : string
publicgetScheme() : string
publicisShared() : bool
publicsetPath(string $path) : \UserFrosting\UniformResourceLocator\static
publicsetPrefix(string $prefix) : \UserFrosting\UniformResourceLocator\static
publicsetScheme(string $scheme) : \UserFrosting\UniformResourceLocator\static
publicsetShared(bool $shared) : \UserFrosting\UniformResourceLocator\static

This class implements \UserFrosting\UniformResourceLocator\ResourceStreamInterface


Interface: \UserFrosting\UniformResourceLocator\ResourceLocatorInterface

ResourceLocatorInterface Class

VisibilityFunction
publicaddLocation(\UserFrosting\UniformResourceLocator\ResourceLocationInterface $location) : void
Add an existing RessourceLocation instance to the location list
publicaddStream(\UserFrosting\UniformResourceLocator\ResourceStreamInterface $stream) : void
Add an exisitng ResourceStream to the stream list
publicgetBasePath() : string
publicgetLocation(string $name) : \UserFrosting\UniformResourceLocator\ResourceLocationInterface
Get a location instance based on it's name
publicgetLocations() : array
Get a a list of all registered locations
publicgetResource(string uri</strong>,<em>bool</em><strong>uri</strong>, <em>bool</em> <strong>first=false) : \UserFrosting\UniformResourceLocator\resource
Return a resource instance
publicgetResources(string uri</strong>,<em>bool</em><strong>uri</strong>, <em>bool</em> <strong>all=false) : array Array of Resource
Return a list of resources instances
publicgetStream(string $scheme) : \UserFrosting\UniformResourceLocator\ResourceStreamInterface
publicgetStreams() : array
publiclistLocations() : array An array of registered name => location
Return a list of all the locations registered by name
publiclistResources(string uri</strong>,<em>bool</em><strong>uri</strong>, <em>bool</em> <strong>all=false) : array The ressources list
List all ressources found at a given uri.
publiclistStreams() : array An array of registered scheme => location
Return a list of all the stream scheme registered
publiclocationExist(string $name) : bool
Returns true if a location has been defined
publicregisterLocation(string name</strong>,<em>string</em><strong>name</strong>, <em>string</em> <strong>path=null) : \UserFrosting\UniformResourceLocator\static
Register a new location
publicregisterStream(string scheme</strong>,<em>string</em><strong>scheme</strong>, <em>string</em> <strong>prefix='', string/array/null paths=null</strong>,<em>bool</em><strong>paths=null</strong>, <em>bool</em> <strong>shared=false) : void
Register a new stream
publicremoveLocation(string $name) : \UserFrosting\UniformResourceLocator\static
Unregister the specified location
publicremoveStream(string $scheme) : \UserFrosting\UniformResourceLocator\static
Unregister the specified stream
publicschemeExists(string $scheme) : bool
Returns true if a stream has been defined

This class implements \RocketTheme\Toolbox\ResourceLocator\ResourceLocatorInterface


Interface: \UserFrosting\UniformResourceLocator\ResourceInterface

Resource Interface

VisibilityFunction
publicgetAbsolutePath() : string
publicgetBasePath() : string
Get the resource base path, aka the path that comes after the ://.
publicgetBasename() : string
Extract the trailing name component (test.txt -> test.txt)
publicgetExtension() : string
Extract the resource extension (test.txt -> txt)
publicgetFilename() : string
Extract the resource filename (test.txt -> test)
publicgetLocation() : \UserFrosting\UniformResourceLocator\ResourceLocationInterface
publicgetLocatorBasePath() : string
publicgetPath() : string
publicgetSeparator() : string
publicgetStream() : \UserFrosting\UniformResourceLocator\ResourceStream
publicgetUri() : string
Get Resource URI
publicsetLocatorBasePath(string $locatorBasePath) : \UserFrosting\UniformResourceLocator\static
publicsetSeparator(string $separator) : \UserFrosting\UniformResourceLocator\static

Class: \UserFrosting\UniformResourceLocator\Resource

Resource Class Resources are used to represent a file with info regarding the stream and Location used to find it. When a resource is created, we save the stream used to find it, the location where it was found, and the absolute and relative paths of the file. Using this information, we can later rebuilt the URI used to find this file. Since the full path will contains the relative location of the stream and location inside the filesystem, this information will be removed to recrete the relative 'basepath' of the file, allowing the recreatation of the uri (scheme://basePath).

VisibilityFunction
public__construct(\UserFrosting\UniformResourceLocator\ResourceStreamInterface stream</strong>, <em>[\UserFrosting\UniformResourceLocator\ResourceLocationInterface](#interface-userfrostinguniformresourcelocatorresourcelocationinterface)/null/[\UserFrosting\UniformResourceLocator\ResourceLocationInterface](#interface-userfrostinguniformresourcelocatorresourcelocationinterface)</em> <strong>location=null, string path</strong>,<em>string</em><strong>path</strong>, <em>string</em> <strong>locatorBasePath='') : void
Constructor
public__toString() : string The resource absolute path
Magic function to convert the class into the resource absolute path
publicgetAbsolutePath() : string
publicgetBasePath() : string
Get the resource base path, aka the path that comes after the ://. To to this, we use the relative path and remove the stream and location base path. For example, a stream with a base path of data/foo/, will return a relative path for every resource it find as data/foo/filename.txt. So we want to remove the data/foo/ part to keep only the filename.txt part, aka the part after the :// in the URI. Same goes for the location part, which comes before the stream: locations/locationA/data/foo
publicgetBasename() : string
Extract the trailing name component (test.txt -> test.txt)
publicgetExtension() : string
Extract the resource extension (test.txt -> txt)
publicgetFilename() : string
Extract the resource filename (test.txt -> test)
publicgetLocation() : \UserFrosting\UniformResourceLocator\ResourceLocationInterface
publicgetLocatorBasePath() : string
publicgetPath() : string
publicgetSeparator() : string
publicgetStream() : \UserFrosting\UniformResourceLocator\ResourceStreamInterface
publicgetUri() : string
Get Resource URI Also adds the prefix stream prefix if it existprefix.
publicsetLocatorBasePath(string $locatorBasePath) : \UserFrosting\UniformResourceLocator\static
publicsetSeparator(string $separator) : \UserFrosting\UniformResourceLocator\static

This class implements \UserFrosting\UniformResourceLocator\ResourceInterface


Class: \UserFrosting\UniformResourceLocator\ResourceLocator

ResourceLocator Class The locator is used to find resources.

VisibilityFunction
public__construct(string/string/null $basePath='') : void
Constructor
public__invoke(string $uri) : string/bool
publicaddLocation(\UserFrosting\UniformResourceLocator\ResourceLocationInterface $location) : void
Add an existing RessourceLocation instance to the location list
publicaddPath(string scheme</strong>,<em>string</em><strong>scheme</strong>, <em>string</em> <strong>prefix, string/array paths</strong>,<em>bool/bool/string</em><strong>paths</strong>, <em>bool/bool/string</em> <strong>override=false, bool $force=false) : void
AddPath function. Used to preserve compatibility with RocketTheme/Toolbox
publicaddStream(\UserFrosting\UniformResourceLocator\ResourceStreamInterface $stream) : \UserFrosting\UniformResourceLocator\static
Add an exisitng ResourceStream to the stream list
publicfindResource(string uri</strong>,<em>bool</em><strong>uri</strong>, <em>bool</em> <strong>absolute=true, bool $first=false) : string The ressource path
Find highest priority instance from a resource. Return the path for said resource For example, if looking for a test.json ressource, only the top priority instance of test.json found will be returned.
publicfindResources(string uri</strong>,<em>bool</em><strong>uri</strong>, <em>bool</em> <strong>absolute=true, bool $all=false) : array[string] An array of all the ressources path
Find all instances from a resource. Return an array of paths for said resource For example, if looking for a test.json ressource, all instance of test.json found will be listed.
publicgetBasePath() : string
publicgetLocation(string $name) : \UserFrosting\UniformResourceLocator\ResourceLocationInterface
Get a location instance based on it's name
publicgetLocations() : \UserFrosting\UniformResourceLocator\array[ResourceLocationInterface]
Get a a list of all registered locations
publicgetResource(string uri</strong>,<em>bool</em><strong>uri</strong>, <em>bool</em> <strong>first=false) : \UserFrosting\UniformResourceLocator\ResourceInterface
Return a resource instance
publicgetResources(string uri</strong>,<em>bool</em><strong>uri</strong>, <em>bool</em> <strong>all=false) : array[ResourceInterface] Array of Resource
Return a list of resources instances
publicgetStream(string $scheme) : \UserFrosting\UniformResourceLocator\ResourceStreamInterface
publicgetStreamBuilder() : \RocketTheme\Toolbox\StreamWrapper\StreamBuilder
publicgetStreams() : \UserFrosting\UniformResourceLocator\array[ResourceStreamInterface]
publicisStream(string $uri) : bool True if is resolvable
Returns true if uri is resolvable by using locator.
publiclistLocations() : array[string] An array of registered name => location
Return a list of all the locations registered by name
publiclistResources(string uri</strong>,<em>bool</em><strong>uri</strong>, <em>bool</em> <strong>all=false, bool $sort=true) : array[ResourceInterface] The ressources list
List all ressources found at a given uri. Same as listing all file in a directory, except here all topmost ressources will be returned when considering all locations
publiclistStreams() : array[string] An array of registered scheme => location
Return a list of all the stream scheme registered
publiclocationExist(string $name) : bool
Returns true if a location has been defined
publicnormalize(string uri</strong>,<em>bool</em><strong>uri</strong>, <em>bool</em> <strong>throwException=false, bool splitStream=false</strong>)</strong>:<em>string/array/bool</em><br/><em>ReturnsthecanonicalizedURIonsuccess.Theresultingpathwillhaveno/./or/../components.Trailingdelimiter/iskept.CanalsosplittheschemeforthepathpartoftheuriifsplitStream=false</strong>)</strong> : <em>string/array/bool</em><br /><em>Returns the canonicalized URI on success. The resulting path will have no '/./' or '/../' components. Trailing delimiter `/` is kept. Can also split the `scheme` for the `path` part of the uri if splitStream parameter is set to true By default (if $throwException parameter is not set to true) returns false on failure.
publicregisterLocation(string name</strong>,<em>string</em><strong>name</strong>, <em>string</em> <strong>path=null) : \UserFrosting\UniformResourceLocator\static
Register a new location
publicregisterStream(string scheme</strong>,<em>string</em><strong>scheme</strong>, <em>string</em> <strong>prefix='', string/array/null paths=null</strong>,<em>bool</em><strong>paths=null</strong>, <em>bool</em> <strong>shared=false) : \UserFrosting\UniformResourceLocator\static
Register a new stream
publicremoveLocation(string $name) : \UserFrosting\UniformResourceLocator\static
Unregister the specified location
publicremoveStream(string $scheme) : \UserFrosting\UniformResourceLocator\static
Unregister the specified stream
publicreset() : \UserFrosting\UniformResourceLocator\static
Reset locator by removing all the registered streams and locations.
publicschemeExists(string $scheme) : bool
Returns true if a stream has been defined
publicsetBasePath(string/null $basePath) : \UserFrosting\UniformResourceLocator\static
protectedfind(string scheme</strong>,<em>string</em><strong>scheme</strong>, <em>string</em> <strong>file, bool array</strong>,<em>bool</em><strong>array</strong>, <em>bool</em> <strong>all) : \UserFrosting\UniformResourceLocator\ResourceInterface/\UserFrosting\UniformResourceLocator\array[ResourceInterface]
Returns path of a file (or directory) based on a search uri
protectedfindCached(string uri</strong>,<em>bool</em><strong>uri</strong>, <em>bool</em> <strong>array, bool $all) : \UserFrosting\UniformResourceLocator\array[ResourceInterface]/ResourceInterface The ressource path or an array of all the ressources path
Find a resource from the cached properties
protectedsearchPaths(\UserFrosting\UniformResourceLocator\ResourceStreamInterface $stream) : array[ResourceLocationInterface] The search paths based on this stream and all available locations
Build the search path out of the defined strean and locations. If the scheme is shared, we don't need to involve locations and can return it's path directly
protectedsetupStreamWrapper(string $scheme) : void
Register the scheme as a php stream wrapper
protectedunsetStreamWrapper(string $scheme) : void
Unset a php stream wrapper

This class implements \UserFrosting\UniformResourceLocator\ResourceLocatorInterface, \RocketTheme\Toolbox\ResourceLocator\ResourceLocatorInterface


Interface: \UserFrosting\UniformResourceLocator\ResourceStreamInterface

ResourceStreamInterface Interface

VisibilityFunction
publicgetPath() : string
publicgetPrefix() : string
publicgetScheme() : string
publicisShared() : bool
publicsetPath(string $path) : \UserFrosting\UniformResourceLocator\static
publicsetPrefix(string $prefix) : \UserFrosting\UniformResourceLocator\static
publicsetScheme(string $scheme) : \UserFrosting\UniformResourceLocator\static
publicsetShared(bool $shared) : \UserFrosting\UniformResourceLocator\static

Class: \UserFrosting\UniformResourceLocator\Exception\StreamNotFoundException

StreamNotFoundException Used when a path is not registered.

VisibilityFunction

This class extends \Exception

This class implements \Throwable


Class: \UserFrosting\UniformResourceLocator\Exception\LocationNotFoundException

LocationNotFoundException Used when a Location is not registered.

VisibilityFunction

This class extends \Exception

This class implements \Throwable