Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PreferencesResolving.php
Go to the documentation of this file.
1 <?php
8 
10 
12 {
19  public function modify(array $config)
20  {
21  if (!isset($config['arguments'], $config['preferences'])) {
22  return $config;
23  }
24 
25  $this->resolvePreferences($config['arguments'], $config['preferences']);
26 
27  return $config;
28  }
29 
37  private function resolvePreferences(&$argument, &$preferences)
38  {
39  if (!is_array($argument)) {
40  return;
41  }
42 
43  foreach ($argument as $key => &$value) {
44  if (in_array($key, ['_i_', '_ins_'], true)) {
45  $value = $this->resolvePreferenceRecursive($value, $preferences);
46  continue;
47  }
48 
49  if (is_array($value)) {
50  $this->resolvePreferences($value, $preferences);
51  }
52  }
53  }
54 
63  private function resolvePreferenceRecursive(&$value, &$preferences)
64  {
65  return isset($preferences[$value])
66  ? $this->resolvePreferenceRecursive($preferences[$value], $preferences)
67  : $value;
68  }
69 }
$config
Definition: fraud_order.php:17
$value
Definition: gender.phtml:16