Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

StorageConnectionFactory.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Bundle\EzPublishCoreBundle\ApiLoader;
8
9 use Symfony\Component\DependencyInjection\ContainerAwareInterface;
10 use Symfony\Component\DependencyInjection\ContainerAwareTrait;
11 use InvalidArgumentException;
12
13 class StorageConnectionFactory implements ContainerAwareInterface
14 {
15 use ContainerAwareTrait;
16
18 protected $repositoryConfigurationProvider;
19
20 public function __construct(RepositoryConfigurationProvider $repositoryConfigurationProvider)
21 {
22 $this->repositoryConfigurationProvider = $repositoryConfigurationProvider;
23 }
24
32 public function getConnection()
33 {
34 $repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig();
35 // Taking provided connection name if any.
36 // Otherwise, just fallback to the default connection.
37
38 if (isset($repositoryConfig['storage']['connection'])) {
39 $doctrineConnectionId = sprintf('doctrine.dbal.%s_connection', $repositoryConfig['storage']['connection']);
40 } else {
41 // "database_connection" is an alias to the default connection, set up by DoctrineBundle.
42 $doctrineConnectionId = 'database_connection';
43 }
44
45 if (!$this->container->has($doctrineConnectionId)) {
46 throw new InvalidArgumentException(
47 "Invalid Doctrine connection '{$repositoryConfig['storage']['connection']}' for repository '{$repositoryConfig['alias']}'." .
48 'Valid connections are ' . implode(', ', array_keys($this->container->getParameter('doctrine.connections')))
49 );
50 }
51
52 return $this->container->get($doctrineConnectionId);
53 }
54 }
eZ\Bundle\EzPublishCoreBundle\ApiLoader\RepositoryConfigurationProvider
The repository configuration provider.
Definition: RepositoryConfigurationProvider.php:16
eZ\Bundle\EzPublishCoreBundle\ApiLoader\StorageConnectionFactory
Definition: StorageConnectionFactory.php:14
eZ\Bundle\EzPublishCoreBundle\ApiLoader\StorageConnectionFactory\getConnection
getConnection()
Returns database connection used by database handler.
Definition: StorageConnectionFactory.php:32
eZ\Bundle\EzPublishCoreBundle\ApiLoader\StorageConnectionFactory\$repositoryConfigurationProvider
$repositoryConfigurationProvider
Definition: StorageConnectionFactory.php:18
eZ\Bundle\EzPublishCoreBundle\ApiLoader\StorageConnectionFactory\__construct
__construct(RepositoryConfigurationProvider $repositoryConfigurationProvider)
Definition: StorageConnectionFactory.php:20
eZ\Bundle\EzPublishCoreBundle\ApiLoader
Definition: CacheFactory.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.