FileAccess Orion

AbstractAdapter
in package
implements StorageInterface, EventsCapableInterface

Interfaces, Classes, Traits and Enums

StorageInterface
EventsCapableInterface
Interface indicating that an object composes an EventManagerInterface instance.

Table of Contents

$capabilities  : null|Capabilities
Capabilities of this adapter
$capabilityMarker  : null|object
Marker to change capabilities
$eventHandles  : array<string|int, mixed>
Event handles of this adapter
$events  : null|EventManagerInterface
The used EventManager if any
$options  : mixed
options
$pluginRegistry  : SplObjectStorage
The plugin registry
__construct()  : mixed
Constructor
__destruct()  : void
Destructor
addItem()  : bool
Add an item.
addItems()  : array<string|int, mixed>
Add multiple items.
addPlugin()  : AbstractAdapter
Register a plugin
checkAndSetItem()  : bool
Set an item only if token matches
decrementItem()  : int|bool
Decrement an item.
decrementItems()  : array<string|int, mixed>
Decrement multiple items.
getCaching()  : bool
Get caching enabled.
getCapabilities()  : Capabilities
Get capabilities of this adapter
getEventManager()  : EventManagerInterface
Get the event manager
getItem()  : mixed
Get an item.
getItems()  : array<string|int, mixed>
Get multiple items.
getMetadata()  : array<string|int, mixed>|bool
Get metadata of an item.
getMetadatas()  : array<string|int, mixed>
Get multiple metadata
getOptions()  : AdapterOptions
Get options.
getPluginRegistry()  : SplObjectStorage
Return registry of plugins
hasItem()  : bool
Test if an item exists.
hasItems()  : array<string|int, mixed>
Test multiple items.
hasPlugin()  : bool
Check if a plugin is registered
incrementItem()  : int|bool
Increment an item.
incrementItems()  : array<string|int, mixed>
Increment multiple items.
removeItem()  : bool
Remove an item.
removeItems()  : array<string|int, mixed>
Remove multiple items.
removePlugin()  : AbstractAdapter
Unregister an already registered plugin
replaceItem()  : bool
Replace an existing item.
replaceItems()  : array<string|int, mixed>
Replace multiple existing items.
setCaching()  : AbstractAdapter
Enable/Disable caching.
setItem()  : bool
Store an item.
setItems()  : array<string|int, mixed>
Store multiple items.
setOptions()  : AbstractAdapter
Set options.
touchItem()  : bool
Reset lifetime of an item
touchItems()  : array<string|int, mixed>
Reset lifetime of multiple items.
internalAddItem()  : bool
Internal method to add an item.
internalAddItems()  : array<string|int, mixed>
Internal method to add multiple items.
internalCheckAndSetItem()  : bool
Internal method to set an item only if token matches
internalDecrementItem()  : int|bool
Internal method to decrement an item.
internalDecrementItems()  : array<string|int, mixed>
Internal method to decrement multiple items.
internalGetCapabilities()  : Capabilities
Internal method to get capabilities of this adapter
internalGetItem()  : mixed
Internal method to get an item.
internalGetItems()  : array<string|int, mixed>
Internal method to get multiple items.
internalGetMetadata()  : array<string|int, mixed>|bool
Internal method to get metadata of an item.
internalGetMetadatas()  : array<string|int, mixed>
Internal method to get multiple metadata
internalHasItem()  : bool
Internal method to test if an item exists.
internalHasItems()  : array<string|int, mixed>
Internal method to test multiple items.
internalIncrementItem()  : int|bool
Internal method to increment an item.
internalIncrementItems()  : array<string|int, mixed>
Internal method to increment multiple items.
internalRemoveItem()  : bool
Internal method to remove an item.
internalRemoveItems()  : array<string|int, mixed>
Internal method to remove multiple items.
internalReplaceItem()  : bool
Internal method to replace an existing item.
internalReplaceItems()  : array<string|int, mixed>
Internal method to replace multiple existing items.
internalSetItem()  : bool
Internal method to store an item.
internalSetItems()  : array<string|int, mixed>
Internal method to store multiple items.
internalTouchItem()  : bool
Internal method to reset lifetime of an item
internalTouchItems()  : array<string|int, mixed>
Internal method to reset lifetime of multiple items.
normalizeKey()  : void
Validates and normalizes a key
normalizeKeys()  : void
Validates and normalizes multiple keys
normalizeKeyValuePairs()  : void
Validates and normalizes an array of key-value pairs
triggerException()  : mixed
Trigger an exception event
triggerPost()  : mixed
Triggers the PostEvent and return the result value.
triggerPre()  : ResponseCollection
Trigger a pre event and return the event response collection

Properties

$capabilityMarker

Marker to change capabilities

protected null|object $capabilityMarker

$eventHandles

Event handles of this adapter

protected array<string|int, mixed> $eventHandles = []

$pluginRegistry

The plugin registry

protected SplObjectStorage $pluginRegistry

Registered plugins

Methods

__destruct()

Destructor

public __destruct() : void

detach all registered plugins to free event handles of event manager

Return values
void

addItem()

Add an item.

public addItem(string $key, mixed $value) : bool
Parameters
$key : string
$value : mixed
Tags
throws
ExceptionInterface
triggers

addItem.pre(PreEvent)

triggers

addItem.post(PostEvent)

triggers

addItem.exception(ExceptionEvent)

Return values
bool

addItems()

Add multiple items.

public addItems(array<string|int, mixed> $keyValuePairs) : array<string|int, mixed>
Parameters
$keyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

addItems.pre(PreEvent)

triggers

addItems.post(PostEvent)

triggers

addItems.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Array of not stored keys

checkAndSetItem()

Set an item only if token matches

public checkAndSetItem(mixed $token, string $key, mixed $value) : bool

It uses the token received from getItem() to check if the item has changed before overwriting it.

Parameters
$token : mixed
$key : string
$value : mixed
Tags
throws
ExceptionInterface
see
getItem()
see
setItem()
Return values
bool

decrementItem()

Decrement an item.

public decrementItem(string $key, int $value) : int|bool
Parameters
$key : string
$value : int
Tags
throws
ExceptionInterface
triggers

decrementItem.pre(PreEvent)

triggers

decrementItem.post(PostEvent)

triggers

decrementItem.exception(ExceptionEvent)

Return values
int|bool

The new value on success, false on failure

decrementItems()

Decrement multiple items.

public decrementItems(array<string|int, mixed> $keyValuePairs) : array<string|int, mixed>
Parameters
$keyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

incrementItems.pre(PreEvent)

triggers

incrementItems.post(PostEvent)

triggers

incrementItems.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Associative array of keys and new values

getCaching()

Get caching enabled.

public getCaching() : bool

Alias of getWritable and getReadable.

Tags
see
getWritable()
see
getReadable()
Return values
bool

getCapabilities()

Get capabilities of this adapter

public getCapabilities() : Capabilities
Tags
triggers

getCapabilities.pre(PreEvent)

triggers

getCapabilities.post(PostEvent)

triggers

getCapabilities.exception(ExceptionEvent)

Return values
Capabilities

getItem()

Get an item.

public getItem(string $key[, bool &$success = null ][, mixed &$casToken = null ]) : mixed
Parameters
$key : string
$success : bool = null
$casToken : mixed = null
Tags
throws
ExceptionInterface
triggers

getItem.pre(PreEvent)

triggers

getItem.post(PostEvent)

triggers

getItem.exception(ExceptionEvent)

Return values
mixed

Data on success, null on failure

getItems()

Get multiple items.

public getItems(array<string|int, mixed> $keys) : array<string|int, mixed>
Parameters
$keys : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

getItems.pre(PreEvent)

triggers

getItems.post(PostEvent)

triggers

getItems.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Associative array of keys and values

getMetadata()

Get metadata of an item.

public getMetadata(string $key) : array<string|int, mixed>|bool
Parameters
$key : string
Tags
throws
ExceptionInterface
triggers

getMetadata.pre(PreEvent)

triggers

getMetadata.post(PostEvent)

triggers

getMetadata.exception(ExceptionEvent)

Return values
array<string|int, mixed>|bool

Metadata on success, false on failure

getMetadatas()

Get multiple metadata

public getMetadatas(array<string|int, mixed> $keys) : array<string|int, mixed>
Parameters
$keys : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

getMetadatas.pre(PreEvent)

triggers

getMetadatas.post(PostEvent)

triggers

getMetadatas.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Associative array of keys and metadata

getPluginRegistry()

Return registry of plugins

public getPluginRegistry() : SplObjectStorage
Return values
SplObjectStorage

hasItem()

Test if an item exists.

public hasItem(string $key) : bool
Parameters
$key : string
Tags
throws
ExceptionInterface
triggers

hasItem.pre(PreEvent)

triggers

hasItem.post(PostEvent)

triggers

hasItem.exception(ExceptionEvent)

Return values
bool

hasItems()

Test multiple items.

public hasItems(array<string|int, mixed> $keys) : array<string|int, mixed>
Parameters
$keys : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

hasItems.pre(PreEvent)

triggers

hasItems.post(PostEvent)

triggers

hasItems.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Array of found keys

incrementItem()

Increment an item.

public incrementItem(string $key, int $value) : int|bool
Parameters
$key : string
$value : int
Tags
throws
ExceptionInterface
triggers

incrementItem.pre(PreEvent)

triggers

incrementItem.post(PostEvent)

triggers

incrementItem.exception(ExceptionEvent)

Return values
int|bool

The new value on success, false on failure

incrementItems()

Increment multiple items.

public incrementItems(array<string|int, mixed> $keyValuePairs) : array<string|int, mixed>
Parameters
$keyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

incrementItems.pre(PreEvent)

triggers

incrementItems.post(PostEvent)

triggers

incrementItems.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Associative array of keys and new values

removeItem()

Remove an item.

public removeItem(string $key) : bool
Parameters
$key : string
Tags
throws
ExceptionInterface
triggers

removeItem.pre(PreEvent)

triggers

removeItem.post(PostEvent)

triggers

removeItem.exception(ExceptionEvent)

Return values
bool

removeItems()

Remove multiple items.

public removeItems(array<string|int, mixed> $keys) : array<string|int, mixed>
Parameters
$keys : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

removeItems.pre(PreEvent)

triggers

removeItems.post(PostEvent)

triggers

removeItems.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Array of not removed keys

replaceItem()

Replace an existing item.

public replaceItem(string $key, mixed $value) : bool
Parameters
$key : string
$value : mixed
Tags
throws
ExceptionInterface
triggers

replaceItem.pre(PreEvent)

triggers

replaceItem.post(PostEvent)

triggers

replaceItem.exception(ExceptionEvent)

Return values
bool

replaceItems()

Replace multiple existing items.

public replaceItems(array<string|int, mixed> $keyValuePairs) : array<string|int, mixed>
Parameters
$keyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

replaceItems.pre(PreEvent)

triggers

replaceItems.post(PostEvent)

triggers

replaceItems.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Array of not stored keys

setCaching()

Enable/Disable caching.

public setCaching(bool $flag) : AbstractAdapter

Alias of setWritable and setReadable.

Parameters
$flag : bool
Tags
see
setWritable()
see
setReadable()
Return values
AbstractAdapter

Provides a fluent interface

setItem()

Store an item.

public setItem(string $key, mixed $value) : bool
Parameters
$key : string
$value : mixed
Tags
throws
ExceptionInterface
triggers

setItem.pre(PreEvent)

triggers

setItem.post(PostEvent)

triggers

setItem.exception(ExceptionEvent)

Return values
bool

setItems()

Store multiple items.

public setItems(array<string|int, mixed> $keyValuePairs) : array<string|int, mixed>
Parameters
$keyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

setItems.pre(PreEvent)

triggers

setItems.post(PostEvent)

triggers

setItems.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Array of not stored keys

touchItem()

Reset lifetime of an item

public touchItem(string $key) : bool
Parameters
$key : string
Tags
throws
ExceptionInterface
triggers

touchItem.pre(PreEvent)

triggers

touchItem.post(PostEvent)

triggers

touchItem.exception(ExceptionEvent)

Return values
bool

touchItems()

Reset lifetime of multiple items.

public touchItems(array<string|int, mixed> $keys) : array<string|int, mixed>
Parameters
$keys : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

touchItems.pre(PreEvent)

triggers

touchItems.post(PostEvent)

triggers

touchItems.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Array of not updated keys

internalAddItem()

Internal method to add an item.

protected internalAddItem(string &$normalizedKey, mixed &$value) : bool
Parameters
$normalizedKey : string
$value : mixed
Tags
throws
ExceptionInterface
Return values
bool

internalAddItems()

Internal method to add multiple items.

protected internalAddItems(array<string|int, mixed> &$normalizedKeyValuePairs) : array<string|int, mixed>
Parameters
$normalizedKeyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Array of not stored keys

internalCheckAndSetItem()

Internal method to set an item only if token matches

protected internalCheckAndSetItem(mixed &$token, string &$normalizedKey, mixed &$value) : bool
Parameters
$token : mixed
$normalizedKey : string
$value : mixed
Tags
throws
ExceptionInterface
see
getItem()
see
setItem()
Return values
bool

internalDecrementItem()

Internal method to decrement an item.

protected internalDecrementItem(string &$normalizedKey, int &$value) : int|bool
Parameters
$normalizedKey : string
$value : int
Tags
throws
ExceptionInterface
Return values
int|bool

The new value on success, false on failure

internalDecrementItems()

Internal method to decrement multiple items.

protected internalDecrementItems(array<string|int, mixed> &$normalizedKeyValuePairs) : array<string|int, mixed>
Parameters
$normalizedKeyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Associative array of keys and new values

internalGetItem()

Internal method to get an item.

protected abstract internalGetItem(string &$normalizedKey[, bool &$success = null ][, mixed &$casToken = null ]) : mixed
Parameters
$normalizedKey : string
$success : bool = null
$casToken : mixed = null
Tags
throws
ExceptionInterface
Return values
mixed

Data on success, null on failure

internalGetItems()

Internal method to get multiple items.

protected internalGetItems(array<string|int, mixed> &$normalizedKeys) : array<string|int, mixed>
Parameters
$normalizedKeys : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Associative array of keys and values

internalGetMetadata()

Internal method to get metadata of an item.

protected internalGetMetadata(string &$normalizedKey) : array<string|int, mixed>|bool
Parameters
$normalizedKey : string
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>|bool

Metadata on success, false on failure

internalGetMetadatas()

Internal method to get multiple metadata

protected internalGetMetadatas(array<string|int, mixed> &$normalizedKeys) : array<string|int, mixed>
Parameters
$normalizedKeys : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Associative array of keys and metadata

internalHasItem()

Internal method to test if an item exists.

protected internalHasItem(string &$normalizedKey) : bool
Parameters
$normalizedKey : string
Tags
throws
ExceptionInterface
Return values
bool

internalHasItems()

Internal method to test multiple items.

protected internalHasItems(array<string|int, mixed> &$normalizedKeys) : array<string|int, mixed>
Parameters
$normalizedKeys : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Array of found keys

internalIncrementItem()

Internal method to increment an item.

protected internalIncrementItem(string &$normalizedKey, int &$value) : int|bool
Parameters
$normalizedKey : string
$value : int
Tags
throws
ExceptionInterface
Return values
int|bool

The new value on success, false on failure

internalIncrementItems()

Internal method to increment multiple items.

protected internalIncrementItems(array<string|int, mixed> &$normalizedKeyValuePairs) : array<string|int, mixed>
Parameters
$normalizedKeyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Associative array of keys and new values

internalRemoveItem()

Internal method to remove an item.

protected abstract internalRemoveItem(string &$normalizedKey) : bool
Parameters
$normalizedKey : string
Tags
throws
ExceptionInterface
Return values
bool

internalRemoveItems()

Internal method to remove multiple items.

protected internalRemoveItems(array<string|int, mixed> &$normalizedKeys) : array<string|int, mixed>
Parameters
$normalizedKeys : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Array of not removed keys

internalReplaceItem()

Internal method to replace an existing item.

protected internalReplaceItem(string &$normalizedKey, mixed &$value) : bool
Parameters
$normalizedKey : string
$value : mixed
Tags
throws
ExceptionInterface
Return values
bool

internalReplaceItems()

Internal method to replace multiple existing items.

protected internalReplaceItems(array<string|int, mixed> &$normalizedKeyValuePairs) : array<string|int, mixed>
Parameters
$normalizedKeyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Array of not stored keys

internalSetItem()

Internal method to store an item.

protected abstract internalSetItem(string &$normalizedKey, mixed &$value) : bool
Parameters
$normalizedKey : string
$value : mixed
Tags
throws
ExceptionInterface
Return values
bool

internalSetItems()

Internal method to store multiple items.

protected internalSetItems(array<string|int, mixed> &$normalizedKeyValuePairs) : array<string|int, mixed>
Parameters
$normalizedKeyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Array of not stored keys

internalTouchItem()

Internal method to reset lifetime of an item

protected internalTouchItem(string &$normalizedKey) : bool
Parameters
$normalizedKey : string
Tags
throws
ExceptionInterface
Return values
bool

internalTouchItems()

Internal method to reset lifetime of multiple items.

protected internalTouchItems(array<string|int, mixed> &$normalizedKeys) : array<string|int, mixed>
Parameters
$normalizedKeys : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Array of not updated keys

normalizeKey()

Validates and normalizes a key

protected normalizeKey(string &$key) : void
Parameters
$key : string
Tags
throws
InvalidArgumentException

On an invalid key

Return values
void

normalizeKeys()

Validates and normalizes multiple keys

protected normalizeKeys(array<string|int, mixed> &$keys) : void
Parameters
$keys : array<string|int, mixed>
Tags
throws
InvalidArgumentException

On an invalid key

Return values
void

normalizeKeyValuePairs()

Validates and normalizes an array of key-value pairs

protected normalizeKeyValuePairs(array<string|int, mixed> &$keyValuePairs) : void
Parameters
$keyValuePairs : array<string|int, mixed>
Tags
throws
InvalidArgumentException

On an invalid key

Return values
void

triggerException()

Trigger an exception event

protected triggerException(string $eventName, ArrayObject $args, mixed &$result, Exception $exception) : mixed

If the ExceptionEvent has the flag "throwException" enabled throw the exception after trigger else return the result.

Parameters
$eventName : string
$args : ArrayObject
$result : mixed
$exception : Exception
Tags
throws
ExceptionInterface
Return values
mixed

triggerPost()

Triggers the PostEvent and return the result value.

protected triggerPost(string $eventName, ArrayObject $args, mixed &$result) : mixed
Parameters
$eventName : string
$args : ArrayObject
$result : mixed
Return values
mixed

triggerPre()

Trigger a pre event and return the event response collection

protected triggerPre(string $eventName, ArrayObject $args) : ResponseCollection
Parameters
$eventName : string
$args : ArrayObject
Return values
ResponseCollection

All handler return values

Search results