/** * Creates a data transformer chain by consuming data found a profile. * The $dataUserOptions is an object that will return info for the output file structure - tree or flat. * * @param \Shopware\Components\SwagImportExport\Profile\Profile $profile * @param array $dataUserOptions * @return \Shopware\Components\SwagImportExport\Transformers\DataTransformerChain */ public function createDataTransformerChain($profile, $dataUserOptions) { // this can be put in a separate hookable function $dataTransformerChain = new DataTransformerChain(); // for every config we create a transformer and add it to the chain $names = $profile->getConfigNames(); foreach ($names as $name) { $config = $profile->getConfig($name); $transformer = $this->createDataTransformer($name, $config); $dataTransformerChain->add($transformer); } // a little hack: if we are in csv, we flatten the tree by adding a flattener at the end if (!$dataUserOptions['isTree']) { $transformer = $this->createDataTransformer('flatten', $profile->getConfig('tree')); $dataTransformerChain->add($transformer); } return $dataTransformerChain; }