abstract class ConnectionManager

Connection manager.

Traits

Configurable trait.

Properties

protected string $default Name of the default connection. from ConfigurableTrait
protected array $configurations Configurations. from ConfigurableTrait
protected array $connections Connections.

Methods

__construct(string $default, array $configurations)

Constructor.

addConfiguration(string $name, array $configuration)

Adds a configuration.

removeConfiguration(string $name)

Removes a configuration.

mixed
connect(string $connection)

Connects to the chosen configuration and returns the connection.

mixed
connection(string|null $connection = null)

Returns the chosen connection.

close(string|null $connection = null)

Closes the chosen connection.

mixed
executeAndClose(Closure $closure, string|null $connection = null)

Executes the passed closure using the chosen connection before closing it.

mixed
__call(string $name, array $arguments)

Magic shortcut to the default connection.

Details

in ConfigurableTrait at line 37
__construct(string $default, array $configurations)

Constructor.

Parameters

string $default Default connection name
array $configurations Configurations

in ConfigurableTrait at line 50
addConfiguration(string $name, array $configuration)

Adds a configuration.

Parameters

string $name Connection name
array $configuration Configuration

in ConfigurableTrait at line 61
removeConfiguration(string $name)

Removes a configuration.

It will also remove any active connection linked to the configuration.

Parameters

string $name Connection name

at line 37
abstract protected mixed connect(string $connection)

Connects to the chosen configuration and returns the connection.

Parameters

string $connection Connection name

Return Value

mixed

at line 45
mixed connection(string|null $connection = null)

Returns the chosen connection.

Parameters

string|null $connection Connection name

Return Value

mixed

at line 62
close(string|null $connection = null)

Closes the chosen connection.

Parameters

string|null $connection Connection name

at line 87
mixed executeAndClose(Closure $closure, string|null $connection = null)

Executes the passed closure using the chosen connection before closing it.

Parameters

Closure $closure Closure to execute
string|null $connection Connection name

Return Value

mixed

at line 103
mixed __call(string $name, array $arguments)

Magic shortcut to the default connection.

Parameters

string $name Method name
array $arguments Method arguments

Return Value

mixed