Skip to content

Commit

Permalink
Merge pull request #14 from digilist/pdo_options
Browse files Browse the repository at this point in the history
Allow to specify pdo options
  • Loading branch information
digilist authored Nov 12, 2018
2 parents a9c233d + 5c119fa commit 29faf4e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
5 changes: 4 additions & 1 deletion demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ output:
gzip: false
database:
driver: pdo_mysql
host: localhost
host: 127.0.0.1
user: root
password: ''
dbname: demo
charset: UTF8
pdo_options:
!php/const PDO::MYSQL_ATTR_SSL_CA: './path-to-ca.pem'
!php/const PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT: true

table_white_list:
- foo
Expand Down
2 changes: 1 addition & 1 deletion src/Command/DumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private function parseConfig(InputInterface $input)
throw new \InvalidArgumentException('Cannot find configuration file: ' . $configArg);
}

$config = Yaml::parse(file_get_contents($configFile));
$config = Yaml::parse(file_get_contents($configFile), Yaml::PARSE_CONSTANT);

$processor = new Processor();
$configuration = new SnakeConfigurationTree();
Expand Down
18 changes: 18 additions & 0 deletions src/Configuration/DatabaseConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,24 @@ public function getConnection()
return $this->get('connection');
}

/**
* @return array
*/
public function getPdoOptions()
{
return $this->get('pdo_options');
}

/**
* @param array $options
*
* @return DatabaseConfiguration
*/
public function setPdoOptions(array $options)
{
return $this->set('pdo_options', $options);
}

protected function parseConfig(array $config)
{
if (!isset($config['connection'])) {
Expand Down
4 changes: 4 additions & 0 deletions src/Configuration/SnakeConfigurationTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public function getConfigTreeBuilder()
->scalarNode('password')->end()
->scalarNode('dbname')->end()
->scalarNode('charset')->end()
->arrayNode('pdo_options')
->prototype('scalar')
->end()
->end()
->end()
->end()
;
Expand Down
1 change: 1 addition & 0 deletions src/Dumper/Sql/ConnectionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ private function connect()
'dbname' => $this->config->getDatabaseName(),
'charset' => $this->config->getCharset(),
'wrapperClass' => \Digilist\SnakeDumper\Dumper\Bridge\Doctrine\DBAL\Connection::class,
'driverOptions' => $this->config->getPdoOptions(),
);

$dbalConfig = new Configuration();
Expand Down

0 comments on commit 29faf4e

Please sign in to comment.