UserFrosting API

SprinkleManager

Sprinkle manager class.

Manages a collection of loaded Sprinkles for the application. Handles Sprinkle class creation, event subscription, services registration, and resource stream registration.

Tags
author

Alex Weissman (https://alexanderweissman.com)

Table of Contents

$ci ContainerInterface
$sprinkles \UserFrosting\System\Sprinkle\Sprinkle[]
$sprinklesPath string
__construct() Create a new SprinkleManager object. mixed
addResources() Register resource streams for all base sprinkles. mixed
addSprinkleResources() Register a sprinkle as a locator location. mixed
getSprinklePath() Returns sprinkle base path from name. string
getSprinkleClass() Returns the sprinkle class. string
getSprinkleClassNamespace() Returns the claculated sprinkle namespace. string
getSprinkleDefaultServiceProvider() Returns the sprinkle service provider class. string
bootSprinkle() Takes the name of a Sprinkle, and creates an instance of the initializer object (if defined). mixed
getSprinkleNames() Returns a list of available sprinkle names. string[]
getSprinkles() Returns a list of available sprinkles. \UserFrosting\System\Sprinkle\Sprinkle[]
init() Initialize a list of Sprinkles, instantiating their boot classes (if they exist), and subscribing them to the event dispatcher. mixed
initFromSchema() Initialize all base sprinkles in a specified Sprinkles schema file (e.g. 'sprinkles.json'). mixed
isAvailable() Return if a Sprinkle is available Can be used by other Sprinkles to test if their dependencies are met. bool
getSprinkle() Find sprinkle value from the sprinkles.json. string|bool
registerAllServices() Interate through the list of loaded Sprinkles, and invoke their ServiceProvider classes. mixed
registerServices() Register services for a specified Sprinkle. mixed
getSprinklesPath() Returns sprinklePath parameter. string
setSprinklesPath() Sets sprinklePath parameter. static
loadSchema() Load list of Sprinkles from a JSON schema file (e.g. 'sprinkles.json'). string[]

Properties

$sprinkles

protected \UserFrosting\System\Sprinkle\Sprinkle[] $sprinkles = []

$sprinklesPath

protected string $sprinklesPath = \UserFrosting\SPRINKLES_DIR . \UserFrosting\DS

Methods

__construct()

Create a new SprinkleManager object.

public __construct( $ci : ContainerInterface ) : mixed
Parameters
$ci : ContainerInterface

The global container object, which holds all your services.

Return values
mixed

addResources()

Register resource streams for all base sprinkles.

public addResources( ) : mixed

For each sprinkle, register its resources and then run its initializer.

Return values
mixed

addSprinkleResources()

Register a sprinkle as a locator location.

public addSprinkleResources( $sprinkleName : string ) : mixed
Parameters
$sprinkleName : string
Return values
mixed

getSprinklePath()

Returns sprinkle base path from name.

public getSprinklePath( $sprinkleName : string ) : string
Parameters
$sprinkleName : string
Return values
string

getSprinkleClass()

Returns the sprinkle class.

protected getSprinkleClass( $sprinkleName : string ) : string
Parameters
$sprinkleName : string
Return values
string

getSprinkleClassNamespace()

Returns the claculated sprinkle namespace.

public getSprinkleClassNamespace( $sprinkleName : string ) : string
Parameters
$sprinkleName : string
Return values
string

The Sprinkle Namespace

getSprinkleDefaultServiceProvider()

Returns the sprinkle service provider class.

protected getSprinkleDefaultServiceProvider( $sprinkleName : string ) : string
Parameters
$sprinkleName : string
Return values
string

bootSprinkle()

Takes the name of a Sprinkle, and creates an instance of the initializer object (if defined).

public bootSprinkle( $sprinkleName : string ) : mixed

Creates an object of a subclass of UserFrosting\System\Sprinkle\Sprinkle if defined for the sprinkle (converting to StudlyCase). Otherwise, returns null.

Parameters
$sprinkleName : string

The name of the Sprinkle to initialize.

Return values
mixed

Sprinkle class instance or null if no such class exist

getSprinkleNames()

Returns a list of available sprinkle names.

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

getSprinkles()

Returns a list of available sprinkles.

public getSprinkles( ) : \UserFrosting\System\Sprinkle\Sprinkle[]
Return values
\UserFrosting\System\Sprinkle\Sprinkle[]

init()

Initialize a list of Sprinkles, instantiating their boot classes (if they exist), and subscribing them to the event dispatcher.

public init( $sprinkleNames : string[] ) : mixed
Parameters
$sprinkleNames : string[]
Return values
mixed

initFromSchema()

Initialize all base sprinkles in a specified Sprinkles schema file (e.g. 'sprinkles.json').

public initFromSchema( $schemaPath : string ) : mixed
Parameters
$schemaPath : string
Return values
mixed

isAvailable()

Return if a Sprinkle is available Can be used by other Sprinkles to test if their dependencies are met.

public isAvailable( $sprinkleName : string ) : bool
Parameters
$sprinkleName : string

The name of the Sprinkle

Return values
bool

getSprinkle()

Find sprinkle value from the sprinkles.json.

public getSprinkle( $sprinkleName : string ) : string|bool
Parameters
$sprinkleName : string
Return values
string|bool

Return sprinkle name or false if sprinkle not found

registerAllServices()

Interate through the list of loaded Sprinkles, and invoke their ServiceProvider classes.

public registerAllServices( ) : mixed
Return values
mixed

registerServices()

Register services for a specified Sprinkle.

public registerServices( $sprinkleName : string ) : mixed
Parameters
$sprinkleName : string
Return values
mixed

getSprinklesPath()

Returns sprinklePath parameter.

public getSprinklesPath( ) : string
Return values
string

setSprinklesPath()

Sets sprinklePath parameter.

public setSprinklesPath( $sprinklesPath : string ) : static
Parameters
$sprinklesPath : string
Return values
static

loadSchema()

Load list of Sprinkles from a JSON schema file (e.g. 'sprinkles.json').

protected loadSchema( $schemaPath : string ) : string[]
Parameters
$schemaPath : string
Return values
string[]

Search results