Skip to content

Commit

Permalink
Merge pull request #26 from swiftotter/20-di-container-issues
Browse files Browse the repository at this point in the history
#20 - php-di and guzzle updates
  • Loading branch information
michalbiarda authored Jun 22, 2022
2 parents 763a89e + b8c88d2 commit 952f956
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"description": "A database production to sandbox utility to sanitize data.",
"type": "library",
"require": {
"php-di/php-di": "^5.4",
"php-di/php-di": "^6.0",
"aws/aws-sdk-php": "^3.19",
"symfony/yaml": ">=2.3",
"ericpoe/haystack": "^1.0",
"guzzlehttp/guzzle": "^6.2",
"guzzlehttp/guzzle": "^6.2|^7.0",
"psr/log": "^1.0",
"symfony/console": "^4.4",
"symfony/event-dispatcher": "^4.0"
Expand Down
38 changes: 20 additions & 18 deletions src/System/DependencyConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
* @package default
**/

declare(strict_types=1);

namespace Driver\System;

use DI;
use DI\Definition\Helper\DefinitionHelper;
use Driver\Engines\LocalConnectionInterface;
use Driver\Engines\MySql\Sandbox\Connection;
use Driver\Engines\MySql\Sandbox\Export;
use Driver\Engines\MySql\Sandbox\Import;
use Driver\Engines\RemoteConnectionInterface;
use Driver\Pipeline\Environment;
use Driver\Pipeline\Stage;
Expand All @@ -32,45 +33,46 @@
use Driver\Pipeline\Transport\Primary as TransportPrimary;
use Driver\System\Logs\LoggerInterface;
use Driver\System\Logs\Primary;
use Driver\System\DebugMode;
use Symfony\Component\Console\Application as ConsoleApplication;
use Symfony\Component\Console\Tester\ApplicationTester as ConsoleApplicationTester;

class DependencyConfig
{
private bool $isDebug = false;
private bool $isDebug;

public function __construct(bool $isDebug)
{
$this->isDebug = $isDebug;
}

public function get()
/**
* @return <string, DefinitionHelper>
*/
public function get(): array
{
$output = [
return [
LoggerInterface::class => DI\Factory(function() {
return new Primary();
}),
Environment\EnvironmentInterface::class => DI\factory([Environment\Primary::class, 'create']),
Environment\Factory::class => DI\object()->constructorParameter('type', Environment\Primary::class),
Environment\Factory::class => DI\autowire()->constructorParameter('type', Environment\Primary::class),
Stage\StageInterface::class => DI\factory([Stage\Primary::class, 'create']),
Stage\Factory::class => DI\object()->constructorParameter('type', Stage\Primary::class),
Stage\Factory::class => DI\autowire()->constructorParameter('type', Stage\Primary::class),
Span\SpanInterface::class => DI\factory([Span\Primary::class, 'create']),
Span\Factory::class => DI\object()->constructorParameter('type', Span\Primary::class),
TransportFactory::class => DI\object()->constructorParameter('type', TransportPrimary::class),
DebugMode::class => DI\object()->constructorParameter('debugMode', $this->isDebug),
RemoteConnectionInterface::class => DI\object(
Span\Factory::class => DI\autowire()->constructorParameter('type', Span\Primary::class),
TransportFactory::class => DI\autowire()->constructorParameter('type', TransportPrimary::class),
DebugMode::class => DI\create()->constructor($this->isDebug),
RemoteConnectionInterface::class => DI\autowire(
$this->isDebug ? DebugExternalConnection::class : Connection::class
),
LocalConnectionInterface::class => DI\object(
LocalConnectionInterface::class => DI\autowire(
\Driver\System\LocalConnectionLoader::class
)
];

return $output;
}

public function getForTests()
/**
* @return <string, DefinitionHelper>
*/
public function getForTests(): array
{
return array_merge(
$this->get(),
Expand Down

0 comments on commit 952f956

Please sign in to comment.