|
@@ -35,6 +35,8 @@ use Symfony\Component\Yaml\Yaml;
|
|
|
class ReinstallSourceBase extends SourcePluginBase implements ContainerFactoryPluginInterface, ConfigurablePluginInterface {
|
|
|
use SimpleSourceTrait;
|
|
|
|
|
|
+ const INJECTED_ID_PREFIX = '_reinstall_';
|
|
|
+
|
|
|
|
|
|
* The event_dispatcher service.
|
|
|
*
|
|
@@ -77,7 +79,7 @@ class ReinstallSourceBase extends SourcePluginBase implements ContainerFactoryPl
|
|
|
$parsedRecords = $this->initialParse($configuration);
|
|
|
$this->records = empty($this->configuration['raw'])
|
|
|
? array_map([$this, 'flattenRecord'], $parsedRecords)
|
|
|
- : $parsedRecords;
|
|
|
+ : array_map([$this, 'injectIds'], $parsedRecords);
|
|
|
$eventDispatcher->dispatch(ReinstallEvents::POST_SOURCE_PARSE, new SourceEvent($this));
|
|
|
}
|
|
|
|
|
@@ -172,6 +174,20 @@ class ReinstallSourceBase extends SourcePluginBase implements ContainerFactoryPl
|
|
|
return $this->iterator;
|
|
|
}
|
|
|
|
|
|
+ protected function injectIds(array $record) {
|
|
|
+ $idKeys = array_keys($this->getIds());
|
|
|
+ foreach ($idKeys as $idKey) {
|
|
|
+ $sourceIdKey = substr($idKey, strlen(static::INJECTED_ID_PREFIX));
|
|
|
+ $current = $record[$sourceIdKey];
|
|
|
+ while (is_array($current)) {
|
|
|
+ $current = current($current);
|
|
|
+ }
|
|
|
+ $record[$idKey] = $current;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $record;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* Load then parse the file requested in configuration and return its records.
|
|
|
*
|