Skip to content

Commit e24ea6f

Browse files
authored
Merge pull request #6 from php-etl/fix/interpreter
Changed the way the interpreter is used to avoid an exception
2 parents dc4cf79 + 8b8f81c commit e24ea6f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Service.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,35 +64,37 @@ public function validate(array $config): bool
6464

6565
public function compile(array $config): Factory\Repository\Extractor|Factory\Repository\Lookup|Factory\Repository\Loader
6666
{
67+
$interpreter = clone $this->interpreter;
68+
6769
if (array_key_exists('expression_language', $config)
6870
&& is_array($config['expression_language'])
6971
&& count($config['expression_language'])
7072
) {
7173
foreach ($config['expression_language'] as $provider) {
72-
$this->interpreter->registerProvider(new $provider);
74+
$interpreter->registerProvider(new $provider);
7375
}
7476
}
7577

76-
$connection = (new Connection($this->interpreter))->compile($config['connection']);
78+
$connection = (new Connection($interpreter))->compile($config['connection']);
7779

7880
if (array_key_exists('extractor', $config)) {
79-
$extractorFactory = new Factory\Extractor($this->interpreter);
81+
$extractorFactory = new Factory\Extractor($interpreter);
8082

8183
return $extractorFactory
8284
->compile($config['extractor'])
8385
->withConnection($connection)
8486
->withBeforeQueries(...($config['before']['queries'] ?? []))
8587
->withAfterQueries(...($config['after']['queries'] ?? []));
8688
} elseif (array_key_exists('lookup', $config)) {
87-
$lookupFactory = new Factory\Lookup($this->interpreter);
89+
$lookupFactory = new Factory\Lookup($interpreter);
8890

8991
return $lookupFactory
9092
->compile($config['lookup'])
9193
->withConnection($connection)
9294
->withBeforeQueries(...($config['before']['queries'] ?? []))
9395
->withAfterQueries(...($config['after']['queries'] ?? []));
9496
} elseif (array_key_exists('loader', $config)) {
95-
$loaderFactory = new Factory\Loader($this->interpreter);
97+
$loaderFactory = new Factory\Loader($interpreter);
9698

9799
return $loaderFactory
98100
->compile($config['loader'])

0 commit comments

Comments
 (0)