Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
BackslashTrim.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'])) {
22  return $config;
23  }
24 
25  $config['arguments'] = $this->resolveInstancesNames($config['arguments']);
26  $this->resolveArguments($config['arguments']);
27 
28  return $config;
29  }
30 
37  private function resolveInstancesNames(array $arguments)
38  {
39  $resolvedInstances = [];
40  foreach ($arguments as $instance => $constructor) {
41  $resolvedInstances[ltrim($instance, '\\')] = $constructor;
42  }
43 
44  return $resolvedInstances;
45  }
46 
53  private function resolveArguments(&$argument)
54  {
55  if (!is_array($argument)) {
56  return;
57  }
58 
59  foreach ($argument as $key => &$value) {
60  if (in_array($key, ['_i_', '_ins_'], true)) {
61  $value = ltrim($value, '\\');
62  continue;
63  }
64 
65  if (is_array($value)) {
66  $this->resolveArguments($value);
67  }
68  }
69  return;
70  }
71 }
$config
Definition: fraud_order.php:17
$value
Definition: gender.phtml:16
$arguments