/**
  * Encrypt constructor.
  *
  * @param \Magento\Framework\Encryption\Encryptor    $encryptor
  * @param \Magento\Framework\Encryption\CryptFactory $cryptFactory
  * @param \Migration\Config                          $configReader
  */
 public function __construct(\Magento\Framework\Encryption\Encryptor $encryptor, \Magento\Framework\Encryption\CryptFactory $cryptFactory, \Migration\Config $configReader)
 {
     $this->cryptFactory = $cryptFactory;
     $this->encryptor = $encryptor;
     $this->configReader = $configReader;
     $this->cryptKey = $this->configReader->getOption(self::CRYPT_KEY);
 }
 /**
  * @param ProgressBar\LogLevelProcessor $progress
  * @param ResourceModel\Source $source
  * @param ResourceModel\Destination $destination
  * @param ResourceModel\RecordFactory $recordFactory
  * @param Logger $logger
  * @param Helper $helper
  * @param Config $config
  */
 public function __construct(ProgressBar\LogLevelProcessor $progress, ResourceModel\Source $source, ResourceModel\Destination $destination, ResourceModel\RecordFactory $recordFactory, Logger $logger, Helper $helper, Config $config)
 {
     $this->source = $source;
     $this->destination = $destination;
     $this->destinationAdapter = $this->destination->getAdapter();
     $this->progress = $progress;
     $this->recordFactory = $recordFactory;
     $this->logger = $logger;
     $this->helper = $helper;
     $this->config = $config;
     $this->copyDirectly = (bool) $this->config->getOption('direct_document_copy');
 }
 /**
  * {@inheritdoc}
  */
 public function handle(array $record)
 {
     if (!$this->isHandling($record)) {
         return false;
     }
     $logFile = $this->config->getOption('log_file');
     $record['formatted'] = $this->getFormatter()->format($record);
     if ($logFile) {
         $filePath = $this->getFilePath($logFile);
         $this->file->filePutContents($filePath, $record['formatted'] . PHP_EOL, FILE_APPEND);
     }
     return false === $this->bubble;
 }
 /**
  * Validating xml file
  *
  * @return $this
  * @throws Exception
  */
 protected function validate()
 {
     $mapFile = $this->config->getOption(self::MAP_FILE_OPTION);
     $rootDir = dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR;
     $configFile = $rootDir . $mapFile;
     if (!is_file($configFile)) {
         throw new Exception('Invalid map filename: ' . $configFile);
     }
     $xml = file_get_contents($configFile);
     $document = $document = new \Magento\Framework\Config\Dom($xml, new \Magento\Framework\App\Arguments\ValidationState(\Magento\Framework\App\State::MODE_DEVELOPER));
     if (!$document->validate($rootDir . 'etc/' . self::CONFIGURATION_SCHEMA)) {
         throw new Exception('XML file is invalid.');
     }
     $this->xml = new \DOMXPath($document->getDom());
     return $this;
 }
 /**
  * Validating xml file
  *
  * @return $this
  * @throws Exception
  */
 protected function validate()
 {
     $mapFile = $this->config->getOption(self::MAP_FILE_OPTION);
     $rootDir = dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR;
     $configFile = $rootDir . $mapFile;
     if (!is_file($configFile)) {
         throw new Exception('Invalid map filename: ' . $configFile);
     }
     $xml = file_get_contents($configFile);
     $document = $document = new \Magento\Framework\Config\Dom($xml, new \Magento\Framework\App\Arguments\ValidationState(\Magento\Framework\App\State::MODE_DEVELOPER));
     $schemaFileName = $rootDir . 'etc/' . self::CONFIGURATION_SCHEMA;
     if (!$document->validate($schemaFileName)) {
         $errors = $document->validateDomDocument($document->getDom(), $schemaFileName, $document::ERROR_FORMAT_DEFAULT);
         foreach ($errors as $error) {
             echo $error . PHP_EOL;
         }
         throw new Exception('XML file is invalid.');
     }
     $this->xml = new \DOMXPath($document->getDom());
     return $this;
 }
Beispiel #6
0
 /**
  * @param ProgressBar\LogLevelProcessor $progressBar
  * @param Resource\Source $source
  * @param Resource\Destination $destination
  * @param Resource\RecordFactory $recordFactory
  * @param \Migration\RecordTransformerFactory $recordTransformerFactory
  * @param MapFactory $mapFactory
  * @param Progress $progress
  * @param Logger $logger
  * @param Config $config
  */
 public function __construct(ProgressBar\LogLevelProcessor $progressBar, Resource\Source $source, Resource\Destination $destination, Resource\RecordFactory $recordFactory, \Migration\RecordTransformerFactory $recordTransformerFactory, MapFactory $mapFactory, Progress $progress, Logger $logger, Config $config)
 {
     $this->source = $source;
     $this->destination = $destination;
     $this->recordFactory = $recordFactory;
     $this->recordTransformerFactory = $recordTransformerFactory;
     $this->map = $mapFactory->create('map_file');
     $this->progressBar = $progressBar;
     $this->progress = $progress;
     $this->logger = $logger;
     $this->config = $config;
     $this->copyDirectly = (bool) $this->config->getOption('direct_document_copy');
 }
 public function setAttributeData(Record\Collection $destinationRecords, array $recordAttributesData, array $attributeCodes)
 {
     /** @var Record $record */
     foreach ($destinationRecords as $record) {
         if (isset($recordAttributesData[$record->getValue('entity_id')])) {
             if ($this->configReader->getOption(self::UPGRADE_CUSTOMER_PASSWORD_HASH)) {
                 $recordAttributesData = $this->upgradeCustomerHash($recordAttributesData, $record->getValue('entity_id'));
             }
             $data = $record->getData();
             $data = array_merge(array_fill_keys($attributeCodes, null), $data, $recordAttributesData[$record->getValue('entity_id')]);
             $record->setData($data);
         }
     }
 }
Beispiel #8
0
 /**
  * Retrieving bulk size
  *
  * @param string $documentName
  * @return mixed
  */
 public function getPageSize($documentName)
 {
     if (array_key_exists($documentName, $this->documentBulkSize)) {
         return $this->documentBulkSize[$documentName];
     }
     $configValue = (int) $this->configReader->getOption('bulk_size');
     if ($configValue === 0) {
         $fields = $this->getDocument($documentName)->getStructure()->getFields();
         $fieldsNumber = count($fields);
         $memoryLimit = $this->getBytes(ini_get('memory_limit'));
         $pageSize = ceil($memoryLimit / (self::MEMORY_PER_FIELD * $fieldsNumber));
     } else {
         $pageSize = $configValue > 0 ? $configValue : self::DEFAULT_BULK_SIZE;
     }
     $pageSize = $pageSize > self::MAX_BULK_SIZE ? self::MAX_BULK_SIZE : $pageSize;
     $this->documentBulkSize[$documentName] = $pageSize;
     return $this->documentBulkSize[$documentName];
 }
Beispiel #9
0
 /**
  * Create groups from file specified in config option
  *
  * @param string $configOption
  * @return \Migration\Reader\Groups
  */
 public function create($configOption)
 {
     $groupsFile = $this->config->getOption($configOption);
     return $this->objectManager->create($this->instanceName, ['groupsFile' => $groupsFile]);
 }
 /**
  * Create class instance with specified parameters
  *
  * @param array $data
  * @return AdapterInterface
  */
 public function create(array $data = [])
 {
     $classNameInConfig = $this->configReader->getOption('resource_adapter_class_name');
     $className = !empty($classNameInConfig) ? $classNameInConfig : $this->defaultClassName;
     return $this->objectManager->create($className, $data);
 }
Beispiel #11
0
 /**
  * @return void
  */
 protected function initProgressBar()
 {
     $this->progressBar = $this->progressBarFactory->create($this->getOutputInstance());
     $this->progressBar->setFormat($this->config->getOption(self::PROGRESS_BAR_FORMAT_OPTION));
 }
 /**
  * Retrieving bulk size
  *
  * @return int
  */
 public function getPageSize()
 {
     $pageSize = (int) $this->configReader->getOption('bulk_size');
     return empty($pageSize) ? self::DEFAULT_BULK_SIZE : $pageSize;
 }