Skip to content

Commit

Permalink
Add teardown function to call the end method (#22)
Browse files Browse the repository at this point in the history
Co-authored-by: Ana Osoeva <ana.osoeva@hdnet.de>
  • Loading branch information
escapevisual and Ana Osoeva committed Oct 26, 2020
1 parent d0a7852 commit 86437d5
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions Classes/Service/Manager.php
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

namespace HDNET\Importr\Service;

use HDNET\Importr\Domain\Model\Import;
Expand Down Expand Up @@ -103,9 +104,7 @@ public function getPreview(Strategy $strategy, $filepath)
$data = [];
$resources = $this->initializeResources($strategy, $filepath);
foreach ($resources as $resource) {
/**
* @var \HDNET\Importr\Service\Resources\ResourceInterface $resource
*/
/** @var \HDNET\Importr\Service\Resources\ResourceInterface $resource */
// Resourcen Object anhand der Datei auswählen
if (\preg_match($resource->getFilepathExpression(), $filepath)) {
// Resource "benutzen"
Expand Down Expand Up @@ -142,6 +141,8 @@ protected function runImport(Import $import)
}
}

$this->teardownTargets($import);

$this->emitSignal('postImport', $import);
}

Expand Down Expand Up @@ -194,6 +195,21 @@ protected function initializeTargets(Import $import)
return $targets;
}

/**
* @param \HDNET\Importr\Domain\Model\Import $import
*/
protected function teardownTargets(Import $import)
{
$targetConfiguration = $import->getStrategy()
->getTargets();
foreach ($targetConfiguration as $target => $configuration) {
$object = $this->objectManager->get($target);
$object->setConfiguration($configuration);
$object->getConfiguration();
$object->end($import->getStrategy());
}
}

/**
* @param int $interval
*/
Expand Down

0 comments on commit 86437d5

Please sign in to comment.