asyncConfigFactory = $asyncConfigFactory; $this->messagePublisher = $publisher; $this->serializer = $json; $this->dir = $dir; $this->file = $file; } /** * @inheritDoc */ public function saveConfigData(array $configData) { $asyncConfig = $this->asyncConfigFactory->create(); $this->saveImages($configData); $asyncConfig->setConfigData($this->serializer->serialize($configData)); $this->messagePublisher->publish('async_config.saveConfig', $asyncConfig); } /** * Save Images to temporary Path * * @param array $configData * @return void * @throws FileSystemException */ private function saveImages(array &$configData) { if (isset($configData['groups']['placeholder'])) { $this->changeImagePath($configData['groups']['placeholder']['fields']); } elseif (isset($configData['groups']['identity'])) { $this->changeImagePath($configData['groups']['identity']['fields']); } } /** * Change Placeholder Data path if exists * * @param array $fields * @return void * @throws FileSystemException */ private function changeImagePath(array &$fields) { foreach ($fields as &$data) { if (!empty($data['value']['tmp_name'])) { $newPath = $this->dir->getPath(DirectoryList::MEDIA) . '/' . // phpcs:ignore Magento2.Functions.DiscouragedFunction pathinfo($data['value']['tmp_name'])['filename']; $this->file->mv( $data['value']['tmp_name'], $newPath ); $data['value']['tmp_name'] = $newPath; } } } }