-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
59 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* Copyright © MagePal LLC. All rights reserved. | ||
* See COPYING.txt for license details. | ||
* http://www.magepal.com | [email protected] | ||
*/ | ||
*/ | ||
|
||
namespace MagePal\CustomerAccountLinksManager\Model\Config\Source; | ||
|
||
|
@@ -14,6 +14,8 @@ class Sections implements \Magento\Framework\Option\ArrayInterface | |
|
||
protected $links; | ||
|
||
protected $list = []; | ||
|
||
public function __construct( | ||
\Magento\Framework\App\Utility\Files $utilityFiles, | ||
\Magento\Framework\View\Element\Html\Links $links | ||
|
@@ -36,47 +38,72 @@ public function getSections() | |
{ | ||
$fileList = $this->utilityFiles->getLayoutFiles(['area_name' => 'frontend'], false); | ||
|
||
$list = []; | ||
|
||
foreach ($fileList as $configFile) { | ||
if (strpos($configFile, 'customer_account.xml') !== false) { | ||
$configXml = simplexml_load_file($configFile); | ||
$this->processXmlElement($configXml); | ||
} | ||
} | ||
|
||
return $this->list; | ||
} | ||
|
||
if ($referenceBlocks = $configXml->body->referenceBlock) { | ||
foreach ($referenceBlocks as $referenceBlock) { | ||
if (!empty($referenceBlock->xpath('block/arguments/argument[@name="label"]'))) { | ||
$list[(string) $referenceBlock->block['name']] = [ | ||
'value' => (string) $referenceBlock->block['name'], | ||
'label' => (string) $referenceBlock->xpath('block/arguments/argument[@name="label"]')[0] | ||
]; | ||
} | ||
/** | ||
* @param $configXml | ||
*/ | ||
protected function processXmlElement($configXml) | ||
{ | ||
if ($referenceBlocks = $configXml->body->referenceBlock) { | ||
foreach ($referenceBlocks as $referenceBlock) { | ||
if (!empty($referenceBlock->xpath('block/arguments/argument[@name="label"]'))) { | ||
$this->updateReferenceBlockList($referenceBlock); | ||
} | ||
} | ||
} | ||
|
||
if (isset($configXml->body->referenceContainer) && isset($configXml->body->referenceContainer->block)) { | ||
if (isset($configXml->body->referenceContainer->block->block) | ||
&& isset($configXml->body->referenceContainer->block->block->block) | ||
) { | ||
$referenceContainerBlocks = $configXml->body->referenceContainer->block->block->block; | ||
|
||
for ($count = 0; $count < count($referenceContainerBlocks); $count++) { | ||
if (!empty($referenceContainerBlocks[$count]->xpath('arguments/argument[@name="label"]'))) { | ||
$this->updateReferenceContainerList($referenceContainerBlocks, $count); | ||
} | ||
} | ||
} elseif (isset($configXml->body->referenceContainer->block->block)) { | ||
$referenceContainerBlocks = $configXml->body->referenceContainer->block->block; | ||
|
||
if (isset($configXml->body->referenceContainer)) { | ||
if ($referenceContainerBlocks = $configXml->body->referenceContainer->block->block->block) { | ||
for ($count = 0; $count < count($referenceContainerBlocks); $count++) { | ||
if (!empty($referenceContainerBlocks[$count]->xpath('arguments/argument[@name="label"]'))) { | ||
$list[(string) $referenceContainerBlocks[$count]['name']] = [ | ||
'value' => (string) $referenceContainerBlocks[$count]['name'], | ||
'label' => (string) $referenceContainerBlocks[$count]->xpath('arguments/argument[@name="label"]')[0] | ||
]; | ||
} | ||
} | ||
} elseif ($referenceContainerBlocks = $configXml->body->referenceContainer->block->block) { | ||
for ($count = 0; $count < count($referenceContainerBlocks); $count++) { | ||
if (!empty($referenceContainerBlocks[$count]->xpath('arguments/argument[@name="label"]'))) { | ||
$list[(string) $referenceContainerBlocks[$count]['name']] = [ | ||
'value' => (string) $referenceContainerBlocks[$count]['name'], | ||
'label' => (string) $referenceContainerBlocks[$count]->xpath('arguments/argument[@name="label"]')[0] | ||
]; | ||
} | ||
} | ||
for ($count = 0; $count < count($referenceContainerBlocks); $count++) { | ||
if (!empty($referenceContainerBlocks[$count]->xpath('arguments/argument[@name="label"]'))) { | ||
$this->updateReferenceContainerList($referenceContainerBlocks, $count); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
return $list; | ||
/** | ||
* @param $rcb | ||
* @param $count | ||
*/ | ||
protected function updateReferenceContainerList($rcb, $count) | ||
{ | ||
$this->list[(string) $rcb[$count]['name']] = [ | ||
'value' => (string) $rcb[$count]['name'], | ||
'label' => (string) $rcb[$count]->xpath('arguments/argument[@name="label"]')[0] | ||
]; | ||
} | ||
|
||
/** | ||
* @param $rb | ||
*/ | ||
protected function updateReferenceBlockList($rb) | ||
{ | ||
$this->list[(string) $rb->block['name']] = [ | ||
'value' => (string) $rb->block['name'], | ||
'label' => (string) $rb->xpath('block/arguments/argument[@name="label"]')[0] | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters