151 $compositeModules = [],
155 $this->_pathToMapFile = $confPathToMapFile;
156 $this->_migrationData = $migrationData;
157 $this->_replacePatterns = [
158 self::FIELD_CONTENT_TYPE_WIKI => $this->_migrationData->getWikiFindPattern(),
159 self::FIELD_CONTENT_TYPE_XML => $this->_migrationData->getXmlFindPattern(),
161 $this->_compositeModules = $compositeModules;
182 $fieldContentType = self::FIELD_CONTENT_TYPE_PLAIN,
183 array $primaryKeyFields = [],
184 $additionalWhere =
'' 186 if (!isset($this->_replaceRules[
$tableName])) {
190 if (!isset($this->_replaceRules[
$tableName][$fieldName])) {
191 $this->_replaceRules[
$tableName][$fieldName] = [
193 'content_type' => $fieldContentType,
194 'pk_fields' => $primaryKeyFields,
195 'additional_where' => $additionalWhere,
207 foreach ($this->_replaceRules as
$tableName => $tableRules) {
221 foreach ($tableRules as $fieldName => $fieldRule) {
246 [
'rows_count' => new \Zend_Db_Expr(
'COUNT(*)')]
248 $fieldName .
' IS NOT NULL' 251 if (!empty($additionalWhere)) {
252 $query->where($additionalWhere);
269 $fieldsToSelect = [$fieldName];
270 if (!empty($fieldRule[
'pk_fields'])) {
271 $fieldsToSelect = array_merge($fieldsToSelect, $fieldRule[
'pk_fields']);
277 $fieldRule[
'additional_where'],
281 $fieldReplacements = [];
282 foreach ($tableData as $rowData) {
284 $rowData[$fieldName],
285 $fieldRule[
'content_type'],
286 $fieldRule[
'entity_type']
290 if (empty($fieldRule[
'pk_fields'])) {
291 $fieldReplacement[
'where_fields'] = [$fieldName => $rowData[$fieldName]];
293 $fieldReplacement[
'where_fields'] = [];
294 foreach ($fieldRule[
'pk_fields'] as $pkField) {
295 $fieldReplacement[
'where_fields'][$pkField] = $rowData[$pkField];
298 $fieldReplacements[] = $fieldReplacement;
315 if (count($fieldReplacements) > 0) {
318 foreach ($fieldReplacements as $fieldReplacement) {
320 foreach ($fieldReplacement[
'where_fields'] as $whereFieldName =>
$value) {
325 [$fieldName => $fieldReplacement[
'to']],
345 array $fieldsToSelect,
346 $additionalWhere =
'',
355 $fieldName .
' IS NOT NULL' 358 if (!empty($additionalWhere)) {
359 $query->where($additionalWhere);
363 $query->limitPage($currPage, $this->_rowsPerPage);
379 switch ($contentType) {
419 $properEntityType =
'';
446 if (preg_match($this->_migrationData->getPlainFindPattern(),
$data, $matches)) {
447 $classAlias = $matches[
'alias'];
472 if (!array_key_exists($contentType, $this->_replacePatterns)) {
477 $pattern = $this->_replacePatterns[$contentType];
478 preg_match_all(
$pattern,
$data, $matches, PREG_PATTERN_ORDER);
479 if (isset($matches[
'alias'])) {
480 $matches = array_unique($matches[
'alias']);
481 foreach ($matches as $classAlias) {
489 foreach ($replacements as $classAlias =>
$className) {
506 $className = implode(
'\\', array_map(
'ucfirst', explode(
'_', $module .
'_' .
$type .
'_' .
$name)));
523 return false !== strpos($factoryName,
'/') || preg_match(
'/^[a-z\d]+(_[A-Za-z\d]+)?$/', $factoryName);
534 if (
false !== strpos($factoryName,
'/')) {
535 list($module,
$name) = explode(
'/', $factoryName);
537 $module = $factoryName;
541 if (
null !== $compositeModuleName) {
542 $module = $compositeModuleName;
543 }
elseif (
false === strpos($module,
'_')) {
544 $module =
"Magento_{$module}";
546 return [$module,
$name];
557 if (array_key_exists($moduleAlias, $this->_compositeModules)) {
558 return $this->_compositeModules[$moduleAlias];
622 if (
null === $this->_aliasesMap) {
623 $this->_aliasesMap = [];
643 if ($this->_directory->isFile($pathToMapFile)) {
644 return $this->_directory->readFile($pathToMapFile);
658 if (isset($matches[
'alias']) && count($matches[
'alias']) > 0) {
659 foreach ($matches[
'alias'] as $key =>
$alias) {
664 $data = str_replace($matches[
'string'][$key], $replaceString,
$data);
680 if ($string && preg_match_all($this->_migrationData->getSerializedFindPattern(), $string, $matches)) {
681 unset($matches[0], $matches[1], $matches[2]);
710 protected function _jsonDecode($encodedValue, $objectDecodeType = 1)
712 return $this->jsonDecode($encodedValue);
723 private function jsonDecode($encodedValue)
725 return $this->serializer->unserialize($encodedValue);
_getAliasFromMap($alias, $entityType='')
_getReplacement($data, $contentType, $entityType='')
const FIELD_CONTENT_TYPE_PLAIN
_getCorrespondingClassName($alias, $entityType='')
_isFactoryName($factoryName)
_updateRowsData($tableName, $fieldName, array $fieldReplacements)
const FIELD_CONTENT_TYPE_XML
elseif(isset( $params[ 'redirect_parent']))
_getPatternReplacement($data, $contentType, $entityType='')
_getClassName($module, $type, $name=null)
_getModuleName($factoryName)
_getCompositeModuleName($moduleAlias)
const FIELD_CONTENT_TYPE_WIKI
appendClassAliasReplace( $tableName, $fieldName, $entityType='', $fieldContentType=self::FIELD_CONTENT_TYPE_PLAIN, array $primaryKeyFields=[], $additionalWhere='')
_updateClassAliasesInTable($tableName, array $tableRules)
_applyFieldRule($tableName, $fieldName, array $fieldRule, $currentPage=0)
_parseSerializedString($string)
_jsonDecode($encodedValue, $objectDecodeType=1)
const ENTITY_TYPE_RESOURCE
_getModelReplacement($data, $entityType='')
const FIELD_CONTENT_TYPE_SERIALIZED
__construct(ModuleDataSetupInterface $setup, Filesystem $filesystem, MigrationData $migrationData, $confPathToMapFile, $compositeModules=[], \Magento\Framework\Serialize\Serializer\Json $serializer=null)
_getTableData( $tableName, $fieldName, array $fieldsToSelect, $additionalWhere='', $currPage=0)
_pushToMap($entityType, $alias, $className)
_getAliasInSerializedStringReplacement($data, $entityType='')
_getRowsCount($tableName, $fieldName, $additionalWhere='')
const SERIALIZED_REPLACE_PATTERN
if(!isset($_GET['name'])) $name