getName(); $isPro = (bool)($fieldInfo->getArguments()['a-pro'] ?? false); $newValue = $this->{$fieldName}; /** * @var mixed $originValue */ $originValue = $originInstance ? $originInstance->{$fieldName} : ($fieldInfo->getArguments()['default_value'] ?? null); $isGroup = $newValue instanceof self; $isGroupArray = is_array($newValue) && count($newValue) > 0 && $newValue[0] instanceof self; $isPlainType = !$isGroup && !$isGroupArray; if (!$isPro && $isPlainType) { continue; } // default value is not available if (is_null($originValue) && $isPlainType) { continue; } if ($isPro && !$isGroup && !$isGroupArray) { $this->{$fieldName} = $originValue; continue; } if ($isGroup) { /** * @var Group $newValue */ $newValue->resetProFields($originValue); continue; } // group array $itemsCount = count($newValue); /** * @var Group[] $newValue */ for ($i = 0; $i < $itemsCount; $i++) { $newValue[$i]->resetProFields($originValue[$i] ?? null); } } } }