UserFrosting API

ResourceLocatorInterface extends ResourceLocatorInterface

ResourceLocatorInterface Class.

Tags
author

Louis Charette

Table of Contents

__invoke() string|bool
addStream() Add an exisitng ResourceStream to the stream list. static
registerStream() Register a new stream. static
removeStream() Unregister the specified stream. static
getStream() Return information about a specfic stream. array
getStreams() Return information about a all registered stream. array>
listStreams() Return a list of all the stream scheme registered. string[]
schemeExists() Returns true if a stream has been defined. bool
addLocation() Add an existing RessourceLocation instance to the location list. static
registerLocation() Register a new location. static
removeLocation() Unregister the specified location. static
getLocation() Get a location instance based on it's name. ResourceLocationInterface
getLocations() Get a a list of all registered locations. \UserFrosting\UniformResourceLocator\ResourceLocationInterface[]
listLocations() Return a list of all the locations registered by name. string[]
locationExist() Returns true if a location has been defined. bool
getResource() Return a resource instance. ResourceInterface|bool
getResources() Return a list of resources instances. \UserFrosting\UniformResourceLocator\ResourceInterface[]
listResources() List all ressources found at a given uri. \UserFrosting\UniformResourceLocator\ResourceInterface[]
getBasePath() string

Methods

__invoke()

public __invoke( $uri : string ) : string|bool
Parameters
$uri : string
Tags
throws
BadMethodCallException
Return values
string|bool

registerStream()

Register a new stream.

public registerStream( $scheme : string [, $prefix : string = '' ] [, $paths : string|string[]|null = null ] [, $shared : bool = false ] ) : static
Parameters
$scheme : string
$prefix : string = ''

(default '')

$paths : string|string[]|null = null

(default null). When using null path, the scheme will be used as a path

$shared : bool = false

(default false) Shared resoureces are not affected by locations

Return values
static

removeStream()

Unregister the specified stream.

public removeStream( $scheme : string ) : static
Parameters
$scheme : string

The stream scheme

Return values
static

getStream()

Return information about a specfic stream.

public getStream( $scheme : string ) : array

Return value is an array of ResourceStreamInterface, for each prefix For example : $array = array( '' => ResourceStreamInterface, 'prefix' => ResourceStreamInterface );.

Parameters
$scheme : string

The stream scheme

Tags
throws
StreamNotFoundException

If stream is not registered

Return values
array

getStreams()

Return information about a all registered stream.

public getStreams( ) : array>

Return value is an array of array of ResourceStreamInterface, for each prefix For example : 'bar' => array( '' => ResourceStreamInterface, 'prefix' => ResourceStreamInterface ), 'foo' => array( '' => ResourceStreamInterface, 'blah' => ResourceStreamInterface );.

Return values
array>

listStreams()

Return a list of all the stream scheme registered.

public listStreams( ) : string[]
Return values
string[]

An array of registered scheme => location

schemeExists()

Returns true if a stream has been defined.

public schemeExists( $scheme : string ) : bool
Parameters
$scheme : string

The stream scheme

Return values
bool

registerLocation()

Register a new location.

public registerLocation( $name : string [, $path : string = null ] ) : static
Parameters
$name : string

The location name

$path : string = null

The location base path (default null)

Return values
static

removeLocation()

Unregister the specified location.

public removeLocation( $name : string ) : static
Parameters
$name : string

The location name

Return values
static

getLocations()

Get a a list of all registered locations.

public getLocations( ) : \UserFrosting\UniformResourceLocator\ResourceLocationInterface[]
Return values
\UserFrosting\UniformResourceLocator\ResourceLocationInterface[]

listLocations()

Return a list of all the locations registered by name.

public listLocations( ) : string[]
Return values
string[]

An array of registered name => location

locationExist()

Returns true if a location has been defined.

public locationExist( $name : string ) : bool
Parameters
$name : string

The location name

Return values
bool

getResource()

Return a resource instance.

public getResource( $uri : string [, $first : bool = false ] ) : ResourceInterface|bool
Parameters
$uri : string

Input URI to be searched (can be a file/path)

$first : bool = false

Whether to return first path even if it doesn't exist.

Return values
ResourceInterface|bool

Returns false if resource is not found

getResources()

Return a list of resources instances.

public getResources( $uri : string [, $all : bool = false ] ) : \UserFrosting\UniformResourceLocator\ResourceInterface[]
Parameters
$uri : string

Input URI to be searched (can be a file/path)

$all : bool = false

Whether to return all paths even if they don't exist.

Return values
\UserFrosting\UniformResourceLocator\ResourceInterface[]

Array of Resources

listResources()

List all ressources found at a given uri.

public listResources( $uri : string [, $all : bool = false ] [, $sort : bool = true ] ) : \UserFrosting\UniformResourceLocator\ResourceInterface[]

Same as listing all file in a directory, except here all topmost ressources will be returned when considering all locations.

Parameters
$uri : string

Input URI to be searched (can be a uri/path ONLY)

$all : bool = false

If true, all resources will be returned, not only topmost ones

$sort : bool = true

Set to true to sort results alphabetically by absolute path. Set to false to sort by absolute priority, higest location first. Default to true.

Return values
\UserFrosting\UniformResourceLocator\ResourceInterface[]

The ressources list

Search results