|
9 | 9 | use Magento\Config\Model\Config\Structure;
|
10 | 10 | use Magento\Config\Model\Config\Structure\Element\AbstractComposite;
|
11 | 11 | use Magento\Config\Model\Config\Structure\Element\Iterator as ElementIterator;
|
12 |
| -use Magento\Config\Model\Config\Structure\ElementInterface; |
13 | 12 |
|
14 | 13 | /**
|
15 | 14 | * Search Config Model
|
@@ -47,34 +46,30 @@ public function __construct(Structure $configStructure, Builder $resultBuilder)
|
47 | 46 | */
|
48 | 47 | public function load()
|
49 | 48 | {
|
50 |
| - if (!$this->hasQuery()) { |
51 |
| - $this->setResults($this->resultBuilder->getAll()); |
52 |
| - return $this; |
53 |
| - } |
54 |
| - |
55 | 49 | $this->findInStructure($this->configStructure->getTabs(), $this->getQuery());
|
56 |
| - |
57 | 50 | $this->setResults($this->resultBuilder->getAll());
|
58 | 51 | return $this;
|
59 | 52 | }
|
60 | 53 |
|
61 | 54 | /**
|
62 | 55 | * @param ElementIterator $structureElementIterator
|
63 |
| - * @param string $needle |
| 56 | + * @param string $searchTerm |
64 | 57 | * @param string $pathLabel
|
| 58 | + * @return void |
| 59 | + * @SuppressWarnings(PHPMD.LongVariable) |
65 | 60 | */
|
66 |
| - public function findInStructure(ElementIterator $structureElementIterator, $needle, $pathLabel = '') |
| 61 | + private function findInStructure(ElementIterator $structureElementIterator, $searchTerm, $pathLabel = '') |
67 | 62 | {
|
| 63 | + if (empty($searchTerm)) { |
| 64 | + return; |
| 65 | + } |
68 | 66 | 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) { |
73 | 68 | $this->resultBuilder->add($structureElement, $pathLabel);
|
74 | 69 | }
|
75 |
| - $elementPathLabel = $pathLabel . '/' . $structureElement->getLabel(); |
| 70 | + $elementPathLabel = $pathLabel . ' / ' . $structureElement->getLabel(); |
76 | 71 | if ($structureElement instanceof AbstractComposite && $structureElement->hasChildren()) {
|
77 |
| - $this->findInStructure($structureElement->getChildren(), $needle, $elementPathLabel); |
| 72 | + $this->findInStructure($structureElement->getChildren(), $searchTerm, $elementPathLabel); |
78 | 73 | }
|
79 | 74 | }
|
80 | 75 | }
|
|
0 commit comments