Skip to content

Commit 4ea2328

Browse files
ENGCOM-3064: Do not use new Phrase in Link Current class #18292
- Merge Pull Request #18292 from VincentMarmiesse/magento2:link-current-do-not-use-new-phrase - Merged commits: 1. cb4b728
2 parents 8460e4e + cb4b728 commit 4ea2328

File tree

2 files changed

+3
-32
lines changed

2 files changed

+3
-32
lines changed

dev/tests/static/testsuite/Magento/Test/Integrity/Library/DependencyTest.php

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -96,35 +96,6 @@ function ($file) {
9696
);
9797
}
9898

99-
public function testAppCodeUsage()
100-
{
101-
$files = Files::init();
102-
$componentRegistrar = new ComponentRegistrar();
103-
$libPaths = $componentRegistrar->getPaths(ComponentRegistrar::LIBRARY);
104-
$invoker = new AggregateInvoker($this);
105-
$invoker(
106-
function ($file) use ($libPaths) {
107-
$content = file_get_contents($file);
108-
foreach ($libPaths as $libPath) {
109-
if (strpos($file, $libPath) === 0) {
110-
$this->assertSame(
111-
0,
112-
preg_match('~(?<![a-z\\d_:]|->|function\\s)__\\s*\\(~iS', $content),
113-
'Function __() is defined outside of the library and must not be used there. ' .
114-
'Replacement suggestion: new \\Magento\\Framework\\Phrase()'
115-
);
116-
}
117-
}
118-
},
119-
$files->getPhpFiles(
120-
Files::INCLUDE_PUB_CODE |
121-
Files::INCLUDE_LIBS |
122-
Files::AS_DATA_SET |
123-
Files::INCLUDE_NON_CLASSES
124-
)
125-
);
126-
}
127-
12899
/**
129100
* @inheritdoc
130101
*/

lib/internal/Magento/Framework/View/Element/Html/Link/Current.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,21 @@ protected function _toHtml()
104104
if ($this->isCurrent()) {
105105
$html = '<li class="nav item current">';
106106
$html .= '<strong>'
107-
. $this->escapeHtml((string)new \Magento\Framework\Phrase($this->getLabel()))
107+
. $this->escapeHtml(__($this->getLabel()))
108108
. '</strong>';
109109
$html .= '</li>';
110110
} else {
111111
$html = '<li class="nav item' . $highlight . '"><a href="' . $this->escapeHtml($this->getHref()) . '"';
112112
$html .= $this->getTitle()
113-
? ' title="' . $this->escapeHtml((string)new \Magento\Framework\Phrase($this->getTitle())) . '"'
113+
? ' title="' . $this->escapeHtml(__($this->getTitle())) . '"'
114114
: '';
115115
$html .= $this->getAttributesHtml() . '>';
116116

117117
if ($this->getIsHighlighted()) {
118118
$html .= '<strong>';
119119
}
120120

121-
$html .= $this->escapeHtml((string)new \Magento\Framework\Phrase($this->getLabel()));
121+
$html .= $this->escapeHtml(__($this->getLabel()));
122122

123123
if ($this->getIsHighlighted()) {
124124
$html .= '</strong>';

0 commit comments

Comments
 (0)