Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
framework
App
DeploymentConfig
Writer
PhpFormatter.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Framework\App\DeploymentConfig\Writer
;
8
12
class
PhpFormatter
implements
FormatterInterface
13
{
17
const
INDENT =
' '
;
18
26
public
function
format($data, array
$comments
= [])
27
{
28
if
(!empty(
$comments
) && is_array($data)) {
29
return
"<?php\nreturn [\n"
. $this->formatData($data,
$comments
) .
"\n];\n"
;
30
}
31
return
"<?php\nreturn "
. $this->varExportShort($data,
true
) .
";\n"
;
32
}
33
42
private
function
formatData($data,
$comments
= [],
$prefix
=
' '
)
43
{
44
$elements = [];
45
46
if
(is_array($data)) {
47
foreach
($data as $key =>
$value
) {
48
if
(!empty(
$comments
[$key])) {
49
$elements[] =
$prefix
.
'";
57
}
58
59
if (is_array($value)) {
60
$elements[] = $prefix . $this->varExportShort($key) . '
=> [
';
61
$elements[] = $this->formatData($value, [], '
' . $prefix);
62
$elements[] = $prefix . '
],
';
63
} else {
64
$elements[] = $prefix . $this->varExportShort($key) . '
=>
' . $this->varExportShort($value) . '
,
';
65
}
66
}
67
return implode("\n", $elements);
68
}
69
70
return var_export($data, true);
71
}
72
81
private function varExportShort($var, int $depth = 0)
82
{
83
if (!is_array($var)) {
84
return var_export($var, true);
85
}
86
87
$indexed = array_keys($var) === range(0, count($var) - 1);
88
$expanded = [];
89
foreach ($var as $key => $value) {
90
$expanded[] = str_repeat(self::INDENT, $depth)
91
. ($indexed ? '
' : $this->varExportShort($key) . '
=>
')
92
. $this->varExportShort($value, $depth + 1);
93
}
94
95
return sprintf("[\n%s\n%s]", implode(",\n", $expanded), str_repeat(self::INDENT, $depth - 1));
96
}
97
}
$prefix
$prefix
Definition:
name.phtml:25
$value
$value
Definition:
gender.phtml:16
$comments
$comments
Definition:
creditmemo_comments_for_search.php:30
Magento\Framework\App\DeploymentConfig\Writer
Definition:
FormatterInterface.php:7