Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SaveProcessor.php
Go to the documentation of this file.
1 <?php
7 
12 
17 {
23  private $valueFactory;
24 
30  private $arrayUtils;
31 
37  private $scopeConfig;
38 
44  public function __construct(
45  ArrayUtils $arrayUtils,
46  PreparedValueFactory $valueBuilder,
47  ScopeConfigInterface $scopeConfig
48  ) {
49  $this->arrayUtils = $arrayUtils;
50  $this->valueFactory = $valueBuilder;
51  $this->scopeConfig = $scopeConfig;
52  }
53 
60  public function process(array $data)
61  {
62  foreach ($data as $scope => $scopeData) {
64  $this->invokeSave($scopeData, $scope);
65  } else {
66  foreach ($scopeData as $scopeCode => $scopeCodeData) {
67  $this->invokeSave($scopeCodeData, $scope, $scopeCode);
68  }
69  }
70  }
71  }
72 
95  private function invokeSave(array $scopeData, $scope, $scopeCode = null)
96  {
97  $scopeData = array_keys($this->arrayUtils->flatten($scopeData));
98 
99  foreach ($scopeData as $path) {
100  $value = $this->scopeConfig->getValue($path, $scope, $scopeCode);
101  $backendModel = $this->valueFactory->create($path, $value, $scope, $scopeCode);
102 
103  if ($backendModel instanceof Value) {
104  $backendModel->beforeSave();
105  $backendModel->afterSave();
106  }
107  }
108  }
109 }
$value
Definition: gender.phtml:16
__construct(ArrayUtils $arrayUtils, PreparedValueFactory $valueBuilder, ScopeConfigInterface $scopeConfig)