Open Data Catalog v2.0.0
DatabaseTableFactory.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use Contracts\FactoryInterface;
6 use Drupal\Core\Database\Connection;
7 
11 class DatabaseTableFactory implements FactoryInterface {
12  private $connection;
13 
14  private $databaseTables = [];
15 
19  public function __construct(Connection $connection) {
20  $this->connection = $connection;
21  }
22 
28  public function getInstance(string $identifier, array $config = []) {
29  if (!isset($config['resource'])) {
30  throw new \Exception("config['resource'] is required");
31  }
32 
33  $resource = $config['resource'];
34 
35  if (!isset($this->databaseTables[$identifier])) {
36  $this->databaseTables[$identifier] = $this->getDatabaseTable($resource);
37  }
38 
39  return $this->databaseTables[$identifier];
40  }
41 
45  protected function getDatabaseTable($resource) {
46  return new DatabaseTable($this->connection, $resource);
47  }
48 
49 }
Drupal\dkan_datastore\Storage\DatabaseTableFactory\getInstance
getInstance(string $identifier, array $config=[])
Definition: DatabaseTableFactory.php:28
Drupal\dkan_datastore\Storage
Definition: DatabaseTable.php:3
Drupal\dkan_datastore\Storage\DatabaseTable
Definition: DatabaseTable.php:16
Drupal\dkan_datastore\Storage\DatabaseTableFactory
Definition: DatabaseTableFactory.php:11
Drupal\dkan_datastore\Storage\DatabaseTableFactory\getDatabaseTable
getDatabaseTable($resource)
Definition: DatabaseTableFactory.php:45
Drupal\dkan_datastore\Storage\DatabaseTableFactory\__construct
__construct(Connection $connection)
Definition: DatabaseTableFactory.php:19