Skip to content

Commit

Permalink
Merge pull request #4 from Viktor2588/feature/withDataSourceAndTarget
Browse files Browse the repository at this point in the history
FEATURE: Dynamic presets
  • Loading branch information
bwaidelich committed Sep 9, 2022
2 parents 03f14e1 + 72012f0 commit f58c2e3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Classes/ImportServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public function create(string $presetName): ImportService
return new ImportService($this->createPreset($presetName));
}

public function createFromPreset(Preset $preset): ImportService
{
return new ImportService($preset);
}

public function createWithFixture(string $presetName): ImportService
{
$preset = $this->createPreset($presetName);
Expand Down
8 changes: 8 additions & 0 deletions Classes/Preset.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ public static function fromConfiguration(array $configuration): self
if (!$dataSource instanceof DataSourceInterface) {
throw new \RuntimeException(sprintf('The configured "source.className" is not an instance of %s', DataSourceInterface::class), 1557238800);
}
return self::fromConfigurationWithDataSource($configuration, $dataSource);
}

/**
* Create a Preset from a given Configuration. Additionally passing extra defined datasource like e.g. ClosureDataSource
*/
public static function fromConfigurationWithDataSource(array $configuration, DataSourceInterface $dataSource): self
{
if (!isset($configuration['mapping'])) {
throw new \RuntimeException(sprintf('Missing "mapping" configuration'), 1558080904);
}
Expand Down

0 comments on commit f58c2e3

Please sign in to comment.