class FeatureManager mixin Decorator

Properties

protected Container $container

The container instance.

protected Decorator> $stores

The array of resolved Pennant stores.

protected Closure> $customCreators

The registered custom driver creators.

protected null|Closure(string): mixed $defaultScopeResolver

The default scope resolver.

protected bool $useMorphMap

Indicates if the Eloquent "morph map" should be used when serializing.

protected string|null $partitionColumn

The column that partitions stored feature values.

protected null|Closure(string): null|int|string $partitionResolver

The resolver of the current partition value.

protected null|FeaturePartition): void $writeGuard

The callback that guards database writes.

Methods

__construct(Container $container)

Create a new Pennant manager instance.

store(string|null $store = null)

Get a Pennant store instance.

driver(string|null $name = null)

Get a Pennant store instance by name.

get(string $name)

Attempt to get the store from the local cache.

resolve(string $name)

Resolve the given store.

callCustomCreator(array $config)

Call a custom driver creator.

createArrayDriver(array $config, string $name)

Create an instance of the array driver.

createDatabaseDriver(array $config, string $name)

Create an instance of the database driver.

storedValueCache(array $config, string $name)

Create the shared cache of a database store's stored values.

array
cacheProfile(string $name, array $cache)

Get the cache store name and TTL of a database store's shared cache.

string|null
databaseConnection(array $config)

Get a database store's connection name, or null for the default connection.

string
databaseTable(array $config)

Get a database store's table.

string
serializeScope(mixed $scope)

Serialize the given scope for storage.

useMorphMap(bool $value = true)

Specify that the Eloquent morph map should be used when serializing.

void
flushCache()

Flush the driver caches.

defaultScopeResolver(string $driver)

The default scope resolver.

void
resolveScopeUsing(callable $resolver)

Set the default scope resolver.

void
resolvePartitionUsing(string $column, Closure $resolver)

Partition stored feature values by the given column.

void
guardWritesUsing(Closure $guard)

Guard database writes, including the first resolution of a stored value.

Closure|null
partitionResolver(string $name, array $config)

The resolver of a store's current partition.

array|null
getConfig(string $name)

Get the Pennant store configuration.

string
getDefaultDriver()

Get the default store name.

void
setDefaultDriver(string $name)

Set the default store name.

forgetDriver(array|string|null $name = null)

Unset the given store instances.

forgetDrivers()

Forget all of the resolved store instances.

extend(string $driver, Closure $callback)

Register a custom driver creator Closure.

setContainer(Container $container)

Set the container instance used by the manager.

mixed
__call(string $method, array $parameters)

Dynamically call the default store instance.

Details

at line 82
__construct(Container $container)

Create a new Pennant manager instance.

Parameters

Container $container

at line 92
Decorator store(string|null $store = null)

Get a Pennant store instance.

Parameters

string|null $store

Return Value

Decorator

Exceptions

InvalidArgumentException

at line 102
Decorator driver(string|null $name = null)

Get a Pennant store instance by name.

Parameters

string|null $name

Return Value

Decorator

Exceptions

InvalidArgumentException

at line 112
protected Decorator get(string $name)

Attempt to get the store from the local cache.

Parameters

string $name

Return Value

Decorator

at line 122
protected Decorator resolve(string $name)

Resolve the given store.

Parameters

string $name

Return Value

Decorator

Exceptions

InvalidArgumentException

at line 156
protected Driver callCustomCreator(array $config)

Call a custom driver creator.

Parameters

array $config

Return Value

Driver

at line 166
ArrayDriver createArrayDriver(array $config, string $name)

Create an instance of the array driver.

Parameters

array $config
string $name

Return Value

ArrayDriver

at line 176
DatabaseDriver createDatabaseDriver(array $config, string $name)

Create an instance of the database driver.

Parameters

array $config
string $name

Return Value

DatabaseDriver

at line 200
protected StoredValueCache|null storedValueCache(array $config, string $name)

Create the shared cache of a database store's stored values.

Writes through any database store must invalidate the values cached by every other store reading the same rows, so each cache configured on an overlapping store is a target. A null connection overlaps every connection because the runtime default can select any.

Parameters

array $config
string $name

Return Value

StoredValueCache|null

at line 249
protected array cacheProfile(string $name, array $cache)

Get the cache store name and TTL of a database store's shared cache.

Parameters

string $name
array $cache

Return Value

array

Exceptions

InvalidArgumentException

at line 266
protected string|null databaseConnection(array $config)

Get a database store's connection name, or null for the default connection.

Parameters

array $config

Return Value

string|null

at line 278
protected string databaseTable(array $config)

Get a database store's table.

Parameters

array $config

Return Value

string

at line 288
string serializeScope(mixed $scope)

Serialize the given scope for storage.

Parameters

mixed $scope

Return Value

string

Exceptions

RuntimeException

at line 311
FeatureManager useMorphMap(bool $value = true)

Specify that the Eloquent morph map should be used when serializing.

On the shared manager, the setting persists for the worker lifetime and changes how every subsequent request serializes model scopes.

Parameters

bool $value

Return Value

FeatureManager

at line 324
void flushCache()

Flush the driver caches.

Only the current coroutine's values are flushed.

Return Value

void

at line 336
protected Closure defaultScopeResolver(string $driver)

The default scope resolver.

Parameters

string $driver

Return Value

Closure

at line 355
void resolveScopeUsing(callable $resolver)

Set the default scope resolver.

On the shared manager, the resolver persists for the worker lifetime and applies to every subsequent request.

Parameters

callable $resolver

Return Value

void

at line 375
void resolvePartitionUsing(string $column, Closure $resolver)

Partition stored feature values by the given column.

The resolver receives the store name and returns the current partition value. Stores configured with "partitioned" set to false are not partitioned.

Register before any store is resolved. On the shared manager, the resolver persists for the worker lifetime and applies to every subsequent request.

Parameters

string $column
Closure $resolver

Return Value

void

Exceptions

InvalidArgumentException
RuntimeException

at line 405
void guardWritesUsing(Closure $guard)

Guard database writes, including the first resolution of a stored value.

Register once, before any store is resolved. On the shared manager, the callback persists on database stores for the worker lifetime and affects every subsequent write.

Parameters

Closure $guard

Return Value

void

Exceptions

RuntimeException

at line 425
protected Closure|null partitionResolver(string $name, array $config)

The resolver of a store's current partition.

Parameters

string $name
array $config

Return Value

Closure|null

at line 450
protected array|null getConfig(string $name)

Get the Pennant store configuration.

Parameters

string $name

Return Value

array|null

at line 458
string getDefaultDriver()

Get the default store name.

Return Value

string

at line 468
void setDefaultDriver(string $name)

Set the default store name.

The default store is process-global config shared by every request in the worker.

Parameters

string $name

Return Value

void

at line 483
FeatureManager forgetDriver(array|string|null $name = null)

Unset the given store instances.

The shared manager's stores serve every request in the worker, and the current coroutine's values for a forgotten store are flushed.

Parameters

array|string|null $name

Return Value

FeatureManager

at line 507
FeatureManager forgetDrivers()

Forget all of the resolved store instances.

The shared manager's stores serve every request in the worker, and the current coroutine's values for the forgotten stores are flushed.

Return Value

FeatureManager

at line 526
FeatureManager extend(string $driver, Closure $callback)

Register a custom driver creator Closure.

On the shared manager, the creator persists for the worker lifetime.

Parameters

string $driver
Closure $callback

Return Value

FeatureManager

at line 542
FeatureManager setContainer(Container $container)

Set the container instance used by the manager.

On the shared manager, the container persists on it and its stores for the worker lifetime.

Parameters

Container $container

Return Value

FeatureManager

at line 559
mixed __call(string $method, array $parameters)

Dynamically call the default store instance.

Parameters

string $method
array $parameters

Return Value

mixed