Propel 2 API
Class

Propel\Runtime\ServiceContainer\StandardServiceContainer

class StandardServiceContainer implements ServiceContainerInterface

Methods

string getDefaultDatasource()

setDefaultDatasource(string $defaultDatasource)

string getAdapterClass(string $name = null)

Get the adapter class for a given datasource.

setAdapterClass(string $name, string $adapterClass)

Set the adapter class for a given datasource.

setAdapterClasses(array $adapterClasses)

Reset existing adapters classes and set new classes for all datasources.

AdapterInterface getAdapter(string $name = null)

Get the adapter for a given datasource.

setAdapter(string $name, AdapterInterface $adapter)

Set the adapter for a given datasource.

setAdapters(array $adapters)

Reset existing adapters and set new adapters for all datasources.

checkVersion(string $generatorVersion)

check whether the given propel generator version has the same version as the propel runtime.

setDatabaseMapClass(string $databaseMapClass)

DatabaseMap getDatabaseMap(string $name = null)

Get the database map for a given datasource.

setDatabaseMap(string $name, DatabaseMap $databaseMap)

Set the database map object to use for a given datasource.

setConnectionManager(string $name, ConnectionManagerInterface $manager)

ConnectionManagerInterface getConnectionManager(string $name)

ConnectionManagerInterface] getConnectionManagers()

closeConnections()

Close any associated resource handles.

ConnectionInterface getConnection(string $name = null, string $mode = ServiceContainerInterface::CONNECTION_WRITE)

Get a connection for a given datasource.

ConnectionInterface getWriteConnection(string $name)

Get a write connection for a given datasource.

ConnectionInterface getReadConnection(string $name)

Get a read connection for a given datasource.

setConnection(string $name, ConnectionInterface $connection)

Shortcut to define a single connection for a datasource.

setProfilerClass(string $profilerClass)

Override the default profiler class.

setProfilerConfiguration(array $profilerConfiguration)

Set the profiler configuration.

setProfiler(Profiler $profiler)

Set the profiler instance.

Profiler getProfiler()

Get a profiler instance.

LoggerInterface getLogger($name = 'defaultLogger')

Get a logger instance

setLogger(string $name, LoggerInterface $logger)

setLoggerConfiguration(string $name, array $loggerConfiguration)

Set the configuration for the logger of a given datasource.

Details

at line 86
public string getDefaultDatasource()

Return Value

string

at line 94
public setDefaultDatasource(string $defaultDatasource)

Parameters

string $defaultDatasource

at line 106
public string getAdapterClass(string $name = null)

Get the adapter class for a given datasource.

Parameters

string $name The datasource name

Return Value

string

at line 123
public setAdapterClass(string $name, string $adapterClass)

Set the adapter class for a given datasource.

This allows for lazy-loading adapter objects in getAdapter().

Parameters

string $name The datasource name
string $adapterClass

at line 134
public setAdapterClasses(array $adapterClasses)

Reset existing adapters classes and set new classes for all datasources.

Parameters

array $adapterClasses A list of adapters

at line 151
public AdapterInterface getAdapter(string $name = null)

Get the adapter for a given datasource.

If the adapter does not yet exist, build it using the related adapterClass.

Parameters

string $name The datasource name

Return Value

AdapterInterface

Exceptions

AdapterException

at line 172
public setAdapter(string $name, AdapterInterface $adapter)

Set the adapter for a given datasource.

Parameters

string $name The datasource name
AdapterInterface $adapter

at line 183
public setAdapters(array $adapters)

Reset existing adapters and set new adapters for all datasources.

Parameters

array $adapters A list of adapters

at line 198
public checkVersion(string $generatorVersion)

check whether the given propel generator version has the same version as the propel runtime.

Parameters

string $generatorVersion

at line 216
public setDatabaseMapClass(string $databaseMapClass)

Parameters

string $databaseMapClass

at line 230
public DatabaseMap getDatabaseMap(string $name = null)

Get the database map for a given datasource.

The database maps are "registered" by the generated map builder classes.

Parameters

string $name The datasource name

Return Value

DatabaseMap

at line 249
public setDatabaseMap(string $name, DatabaseMap $databaseMap)

Set the database map object to use for a given datasource.

Parameters

string $name The datasource name
DatabaseMap $databaseMap

at line 258
public setConnectionManager(string $name, ConnectionManagerInterface $manager)

Parameters

string $name The datasource name
ConnectionManagerInterface $manager

at line 274
public ConnectionManagerInterface getConnectionManager(string $name)

Parameters

string $name The datasource name

Return Value

ConnectionManagerInterface

at line 282
public ConnectionManagerInterface] getConnectionManagers()

Return Value

ConnectionManagerInterface]

at line 293
public closeConnections()

Close any associated resource handles.

This method frees any database connection handles that have been
opened by the getConnection() method.

at line 311
public ConnectionInterface getConnection(string $name = null, string $mode = ServiceContainerInterface::CONNECTION_WRITE)

Get a connection for a given datasource.

If the connection has not been opened, open it using the related
connectionSettings. If the connection has already been opened, return it.

Parameters

string $name The datasource name
string $mode The connection mode (this applies to replication systems).

Return Value

ConnectionInterface A database connection

at line 337
public ConnectionInterface getWriteConnection(string $name)

Get a write connection for a given datasource.

If the connection has not been opened, open it using the related
connectionSettings. If the connection has already been opened, return it.

Parameters

string $name The datasource name that is used to look up the DSN from the runtime configuration file. Empty name not allowed.

Return Value

ConnectionInterface A database connection

Exceptions

AdapterException - if connection is not properly configured

at line 354
public ConnectionInterface getReadConnection(string $name)

Get a read connection for a given datasource.

If the slave connection has not been opened, open it using a random read connection
setting for the related datasource. If no read connection setting exist, return the master
connection. If the slave connection has already been opened, return it.

Parameters

string $name The datasource name that is used to look up the DSN from the runtime configuration file. Empty name not allowed.

Return Value

ConnectionInterface A database connection

at line 365
public setConnection(string $name, ConnectionInterface $connection)

Shortcut to define a single connection for a datasource.

Parameters

string $name The datasource name
ConnectionInterface $connection A database connection

at line 380
public setProfilerClass(string $profilerClass)

Override the default profiler class.

The service container uses this class to instantiate a new profiler when
getProfiler() is called.

Parameters

string $profilerClass

at line 392
public setProfilerConfiguration(array $profilerConfiguration)

Set the profiler configuration.

Parameters

array $profilerConfiguration

See also

\Propel\Runtime\Util\Profiler::setConfiguration()

at line 403
public setProfiler(Profiler $profiler)

Set the profiler instance.

Parameters

Profiler $profiler

at line 415
public Profiler getProfiler()

Get a profiler instance.

If no profiler is set, create one using profilerClass and profilerConfiguration.

Return Value

Profiler

at line 434
public LoggerInterface getLogger($name = 'defaultLogger')

Get a logger instance

Parameters

$name

Return Value

LoggerInterface

at line 447
public setLogger(string $name, LoggerInterface $logger)

Parameters

string $name the name of the logger to be set
LoggerInterface $logger A logger instance

at line 514
public setLoggerConfiguration(string $name, array $loggerConfiguration)

Set the configuration for the logger of a given datasource.

A logger configuration must contain a 'handlers' key defining one
or more handlers of type stream, rotating_file, or syslog.
You can also create more complex loggers by hand and set them directly
using setLogger().

Parameters

string $name
array $loggerConfiguration