21 private $runtimeConfigSource;
28 $this->runtimeConfigSource = $runtimeConfigSource;
41 $runtimeScopeData = $this->changeDataKeyToCode(
42 $this->getRuntimeData($scope)
45 return array_diff_key($runtimeScopeData,
$data);
58 $runtimeScopeData = $this->changeDataKeyToCode(
59 $this->getRuntimeData($scope)
62 return array_diff_key(
$data, $runtimeScopeData);
76 $data = $this->setDefaultValues($scope,
$data);
77 $runtimeScopeData = $this->changeDataKeyToCode(
78 $this->getRuntimeData($scope)
81 foreach ($runtimeScopeData as $entityCode => $entityData) {
82 if (isset(
$data[$entityCode]) && array_diff_assoc($entityData,
$data[$entityCode])) {
83 $itemsToUpdate[$entityCode] = array_replace($entityData,
$data[$entityCode]);
87 return $itemsToUpdate;
97 private function setDefaultValues($scope, array
$data)
102 $fieldset = [
'default_group_id'];
105 $fieldset = [
'website_id',
'default_store_id',
'root_category_id'];
108 $fieldset = [
'website_id',
'group_id'];
112 foreach (
$data as $entityCode => $entityData) {
113 foreach ($fieldset as $field) {
114 $entityData[$field] = !empty($entityData[$field]) ? $entityData[$field] :
'0';
117 $data[$entityCode] = $entityData;
129 private function getRuntimeData($scope)
131 $runtimeData = $this->runtimeConfigSource->get();
133 return (array)$runtimeData[$scope];
142 private function changeDataKeyToCode(array
$data)
144 return array_combine(
145 array_column(
$data,
'code'),
getItemsToUpdate($scope, array $data)
getItemsToCreate($scope, array $data)
__construct(ConfigSourceInterface $runtimeConfigSource)
getItemsToDelete($scope, array $data)