Skip to content

Commit e2e2048

Browse files
committed
PR changes we applied:
- changed visibility of findInStructure() method + renamed its argument - removed unnecessary verifications
1 parent 94b423b commit e2e2048

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

app/code/Magento/Backend/Model/Search/Config.php

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Magento\Config\Model\Config\Structure;
1010
use Magento\Config\Model\Config\Structure\Element\AbstractComposite;
1111
use Magento\Config\Model\Config\Structure\Element\Iterator as ElementIterator;
12-
use Magento\Config\Model\Config\Structure\ElementInterface;
1312

1413
/**
1514
* Search Config Model
@@ -47,34 +46,30 @@ public function __construct(Structure $configStructure, Builder $resultBuilder)
4746
*/
4847
public function load()
4948
{
50-
if (!$this->hasQuery()) {
51-
$this->setResults($this->resultBuilder->getAll());
52-
return $this;
53-
}
54-
5549
$this->findInStructure($this->configStructure->getTabs(), $this->getQuery());
56-
5750
$this->setResults($this->resultBuilder->getAll());
5851
return $this;
5952
}
6053

6154
/**
6255
* @param ElementIterator $structureElementIterator
63-
* @param string $needle
56+
* @param string $searchTerm
6457
* @param string $pathLabel
58+
* @return void
59+
* @SuppressWarnings(PHPMD.LongVariable)
6560
*/
66-
public function findInStructure(ElementIterator $structureElementIterator, $needle, $pathLabel = '')
61+
private function findInStructure(ElementIterator $structureElementIterator, $searchTerm, $pathLabel = '')
6762
{
63+
if (empty($searchTerm)) {
64+
return;
65+
}
6866
foreach ($structureElementIterator as $structureElement) {
69-
if (!($structureElement instanceof ElementInterface)) {
70-
continue;
71-
}
72-
if (stripos((string)$structureElement->getLabel(), $needle) !== false) {
67+
if (mb_stripos((string)$structureElement->getLabel(), $searchTerm) !== false) {
7368
$this->resultBuilder->add($structureElement, $pathLabel);
7469
}
75-
$elementPathLabel = $pathLabel . '/' . $structureElement->getLabel();
70+
$elementPathLabel = $pathLabel . ' / ' . $structureElement->getLabel();
7671
if ($structureElement instanceof AbstractComposite && $structureElement->hasChildren()) {
77-
$this->findInStructure($structureElement->getChildren(), $needle, $elementPathLabel);
72+
$this->findInStructure($structureElement->getChildren(), $searchTerm, $elementPathLabel);
7873
}
7974
}
8075
}

app/code/Magento/Backend/Model/Search/Config/Result/Builder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function getAll()
5555
/**
5656
* @param AbstractComposite|ElementInterface $structureElement
5757
* @param string $elementPathLabel
58+
* @return void
5859
*/
5960
public function add(ElementInterface $structureElement, $elementPathLabel)
6061
{

0 commit comments

Comments
 (0)