AdapterFactory
in package
implements
FactoryInterface
Uses
SecretTrait
Database utility class. May be used as a service or as a standard Laminas factory.
Tags
Interfaces, Classes, Traits and Enums
- FactoryInterface
Table of Contents
- $config : Config
- VuFind configuration
- __construct() : mixed
- Constructor
- __invoke() : object
- Create an object (glue code for FactoryInterface compliance)
- getAdapter() : Adapter
- Obtain a Laminas\DB connection using standard VuFind configuration.
- getAdapterFromArray() : Adapter
- Obtain a Laminas\DB connection using a set of given element.
- getAdapterFromConfig() : Adapter
- Obtain a Laminas\DB connection using the config.
- getAdapterFromConnectionString() : Adapter
- Obtain a Laminas\DB connection using a connection string.
- getAdapterFromOptions() : Adapter
- Obtain a Laminas\DB connection using an option array.
- getDriverName() : string
- Translate the connection string protocol into a driver name.
- getDriverOptions() : array<string|int, mixed>
- Get options for the selected driver.
- getSecretFromConfig() : string|null
- Load a secret value from the specified configuration and key.
Properties
$config
VuFind configuration
protected
Config
$config
Methods
__construct()
Constructor
public
__construct([Config $config = null ]) : mixed
Parameters
- $config : Config = null
-
VuFind configuration (provided when used as service; omitted when used as factory)
Return values
mixed —__invoke()
Create an object (glue code for FactoryInterface compliance)
public
__invoke(ContainerInterface $container, string $requestedName[, null|array<string|int, mixed> $options = null ]) : object
Parameters
- $container : ContainerInterface
-
Service manager
- $requestedName : string
-
Service being created
- $options : null|array<string|int, mixed> = null
-
Extra options (optional)
Tags
Return values
object —getAdapter()
Obtain a Laminas\DB connection using standard VuFind configuration.
public
getAdapter([string $overrideUser = null ][, string $overridePass = null ]) : Adapter
Parameters
- $overrideUser : string = null
-
Username override (leave null to use username from config.ini)
- $overridePass : string = null
-
Password override (leave null to use password from config.ini)
Return values
Adapter —getAdapterFromArray()
Obtain a Laminas\DB connection using a set of given element.
public
getAdapterFromArray(array<string|int, mixed> $config) : Adapter
Parameters
- $config : array<string|int, mixed>
-
Config array to connect to the DB containing driver (ie: mysql), username, password, hostname, database (db name), port
Return values
Adapter —getAdapterFromConfig()
Obtain a Laminas\DB connection using the config.
public
getAdapterFromConfig([string $overrideUser = null ][, string $overridePass = null ]) : Adapter
Parameters
- $overrideUser : string = null
-
Username override (leave null to use username from config)
- $overridePass : string = null
-
Password override (leave null to use password from config)
Return values
Adapter —getAdapterFromConnectionString()
Obtain a Laminas\DB connection using a connection string.
public
getAdapterFromConnectionString(string $connectionString[, string $overrideUser = null ][, string $overridePass = null ]) : Adapter
Parameters
- $connectionString : string
-
Connection string of the form [db_type]://[username]:[password]@[host]/[db_name]
- $overrideUser : string = null
-
Username override (leave null to use username from connection string)
- $overridePass : string = null
-
Password override (leave null to use password from connection string)
Return values
Adapter —getAdapterFromOptions()
Obtain a Laminas\DB connection using an option array.
public
getAdapterFromOptions(array<string|int, mixed> $options) : Adapter
Parameters
- $options : array<string|int, mixed>
-
Options for building adapter
Return values
Adapter —getDriverName()
Translate the connection string protocol into a driver name.
public
getDriverName(string $type) : string
Parameters
- $type : string
-
Database type from connection string
Return values
string —getDriverOptions()
Get options for the selected driver.
protected
getDriverOptions(string $driver) : array<string|int, mixed>
Parameters
- $driver : string
-
Driver name
Return values
array<string|int, mixed> —getSecretFromConfig()
Load a secret value from the specified configuration and key.
protected
getSecretFromConfig(Config|array<string|int, mixed>|null $config, string $key) : string|null
Will look for a _file-suffixed version of the key first, and load the data from a separate file if configured to do so.
Parameters
- $config : Config|array<string|int, mixed>|null
-
The config to read from
- $key : string
-
The key to retrieve