Skip to content

Commit 135ae47

Browse files
committed
Refactor 12488-HTML-Sitemap-Improvements
1 parent d33333b commit 135ae47

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

Block/Additional/AbstractLinks.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function getCollection()
3030
$i = 0;
3131
$pageSize = $this->getPageSize();
3232
$collection = [];
33-
$links = $this->config->getAdditionalLinks() ?: [];
33+
$links = $this->config->getAdditionalLinks();
3434
foreach ($links as $link) {
3535
if (!empty($link['url'])) {
3636
$collection[] = new DataObject([
@@ -44,7 +44,6 @@ protected function getCollection()
4444
if ($i >= $pageSize) {
4545
break;
4646
}
47-
4847
}
4948

5049
$this->setData($k, $collection);

Model/Config.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,20 @@ class Config
6868
private $serializer;
6969

7070
/**
71-
* @param SerializerInterface $serializer
7271
* @param ScopeConfigInterface $scopeConfig
7372
* @param ModuleListInterface|null $moduleList
73+
* @param SerializerInterface|null $serializer
7474
*/
7575
public function __construct(
76-
SerializerInterface $serializer,
7776
ScopeConfigInterface $scopeConfig,
78-
ModuleListInterface $moduleList = null
77+
ModuleListInterface $moduleList = null,
78+
SerializerInterface $serializer = null
7979
) {
80-
$this->serializer = $serializer;
8180
$this->scopeConfig = $scopeConfig;
8281
$this->moduleList = $moduleList ?: \Magento\Framework\App\ObjectManager::getInstance()
8382
->get(ModuleListInterface::class);
83+
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
84+
->get(SerializerInterface::class);
8485
}
8586

8687
/**
@@ -200,16 +201,12 @@ public function getBlockMaxDepth(string $type, $storeId = null): string
200201
public function getAdditionalLinks($storeId = null): array
201202
{
202203
$data = $this->getConfig('mfhs/additionallinks/links', $storeId);
203-
204-
$additionalLinks = [];
205204
if ($data) {
206-
$values = $this->serializer->unserialize($data);
207-
foreach ($values as $item) {
208-
$additionalLinks[] = $item;
209-
}
205+
$additionalLinks = array_values($this->serializer->unserialize($data));
206+
} else {
207+
$additionalLinks = [];
210208
}
211209
return $additionalLinks;
212-
213210
}
214211

215212
/**

0 commit comments

Comments
 (0)