ServiceCloudConsumer
    
            
            in package
            
        
    
    
    
Service cloud consumer implementation which can be used for service or blocker templates.
Table of Contents
Properties
- $dataSources : array<string|int, AbstractDataSource>
- Data sources.
- $invalidatedThroughStorage : mixed
- See getter.
- $invalidatedThroughStorageCurrentTransaction : mixed
- $middlewares : array<string|int, AbstractMiddleware>
- Middlewares.
- $pools : array<string|int, ConsumerPool>
- Consumer pools.
- $retrievingDataTransactionCount : mixed
- $storage : AbstractStorage
- Storage.
- $templates : array<string|int, AbstractTemplate>
- In-memory cache of collected templates of all data sources.
- $typeClass : mixed
- $variableResolver : VariableResolver
- VariableResolver.
Methods
- __construct() : mixed
- C'tor.
- addDataSource() : mixed
- Add data source to our consumer.
- addMiddleware() : mixed
- Add middleware to our consumer.
- addPool() : mixed
- Add new consumer pool.
- getDataSources() : mixed
- Getter.
- getMiddlewares() : mixed
- Getter.
- getPools() : mixed
- Getter.
- getStorage() : mixed
- Getter.
- getTypeClass() : mixed
- Getter.
- getVariableResolver() : mixed
- Getter.
- isInvalidatedThroughStorage() : mixed
- Checks if the current `retrieve()`/`retrieveBy()` statement got invalidated through the storage.
- retrieve() : array<string|int, AbstractTemplate>
- Get all template instances.
- retrieveBy() : array<string|int, AbstractTemplate>
- Get a single template instance by criteria.
- runMiddleware() : mixed
- Run a closure for each middleware type. This also respects `AbstractConsumerMiddleware`.
- setStorage() : mixed
- Setter.
- setVariableResolver() : mixed
- Setter.
- downloadAndPersistFromDataSource() : mixed
- Download templates from data sources and persist to storage. This also respected the `ConsumerPool` if one given.
- downloadFromDataSource() : array<string|int, AbstractTemplate>
- Download templates from data sources. This does not persist anything to the storage, for this use `downloadAndPersistFromDataSource` or `retrieve` instead!
- filterTemplates() : array<string|int, AbstractTemplate>
- Remove unwanted classes from the templates array.
Properties
$dataSources
Data sources.
    private
        array<string|int, AbstractDataSource>
    $dataSources
     = []
    
    
    
$invalidatedThroughStorage
See getter.
    private
        mixed
    $invalidatedThroughStorage
     = false
    
    
    
$invalidatedThroughStorageCurrentTransaction
    private
        mixed
    $invalidatedThroughStorageCurrentTransaction
     = false
    
    
    
$middlewares
Middlewares.
    private
        array<string|int, AbstractMiddleware>
    $middlewares
     = []
    
    
    
$pools
Consumer pools.
    private
        array<string|int, ConsumerPool>
    $pools
     = []
    
    
    
$retrievingDataTransactionCount
    private
        mixed
    $retrievingDataTransactionCount
     = 0
    
    
    
$storage
Storage.
    private
        AbstractStorage
    $storage
    
    
    
    
$templates
In-memory cache of collected templates of all data sources.
    private
        array<string|int, AbstractTemplate>
    $templates
    
    
    
    
$typeClass
    private
        mixed
    $typeClass
    
    
    
    
$variableResolver
VariableResolver.
    private
        VariableResolver
    $variableResolver
    
    
    
    
Methods
__construct()
C'tor.
    public
                    __construct(string $typeClass) : mixed
    Parameters
- $typeClass : string
- 
                    Should be the class which extends from AbstractTemplate
addDataSource()
Add data source to our consumer.
    public
                    addDataSource(AbstractDataSource $dataSource) : mixed
    Parameters
- $dataSource : AbstractDataSource
addMiddleware()
Add middleware to our consumer.
    public
                    addMiddleware(AbstractMiddleware $middleware) : mixed
    Parameters
- $middleware : AbstractMiddleware
addPool()
Add new consumer pool.
    public
                    addPool(ConsumerPool $pool) : mixed
    Parameters
- $pool : ConsumerPool
Tags
getDataSources()
Getter.
    public
                    getDataSources() : mixed
    Tags
getMiddlewares()
Getter.
    public
                    getMiddlewares() : mixed
    Tags
getPools()
Getter.
    public
                    getPools() : mixed
    Tags
getStorage()
Getter.
    public
                    getStorage() : mixed
    Tags
getTypeClass()
Getter.
    public
                    getTypeClass() : mixed
    Tags
getVariableResolver()
Getter.
    public
                    getVariableResolver() : mixed
    Tags
isInvalidatedThroughStorage()
Checks if the current `retrieve()`/`retrieveBy()` statement got invalidated through the storage.
    public
                    isInvalidatedThroughStorage([bool $includePools = true ]) : mixed
    Use this within your middlewares so you can e.g. determine to fetch from an external source or not.
Parameters
- $includePools : bool = true
- 
                    If you run within a pool, it checks the other service cloud consumers within the pool, too 
retrieve()
Get all template instances.
    public
                    retrieve([bool|string $forceInvalidate = false ]) : array<string|int, AbstractTemplate>
    Parameters
- $forceInvalidate : bool|string = false
- 
                    Pass "never"to skip download from data source completely
Return values
array<string|int, AbstractTemplate>retrieveBy()
Get a single template instance by criteria.
    public
                    retrieveBy(string $field, mixed $value[, bool|string $forceInvalidate = false ]) : array<string|int, AbstractTemplate>
    Parameters
- $field : string
- 
                    Can be identifieror your custom implementation which is supported by your storage
- $value : mixed
- $forceInvalidate : bool|string = false
- 
                    Pass "never"to skip download from data source completely
Return values
array<string|int, AbstractTemplate>runMiddleware()
Run a closure for each middleware type. This also respects `AbstractConsumerMiddleware`.
    public
                    runMiddleware(string $middlewareTypeClass, callable $closure) : mixed
    Parameters
- $middlewareTypeClass : string
- $closure : callable
setStorage()
Setter.
    public
                    setStorage(AbstractStorage $storage) : mixed
    Parameters
- $storage : AbstractStorage
Tags
setVariableResolver()
Setter.
    public
                    setVariableResolver(VariableResolver $resolver) : mixed
    Parameters
- $resolver : VariableResolver
Tags
downloadAndPersistFromDataSource()
Download templates from data sources and persist to storage. This also respected the `ConsumerPool` if one given.
    protected
                    downloadAndPersistFromDataSource() : mixed
    Tags
downloadFromDataSource()
Download templates from data sources. This does not persist anything to the storage, for this use `downloadAndPersistFromDataSource` or `retrieve` instead!
    protected
                    downloadFromDataSource() : array<string|int, AbstractTemplate>
    Tags
Return values
array<string|int, AbstractTemplate>filterTemplates()
Remove unwanted classes from the templates array.
    protected
                    filterTemplates(array<string|int, AbstractTemplate> $arr) : array<string|int, AbstractTemplate>
    Parameters
- $arr : array<string|int, AbstractTemplate>