File: D:/HostingSpaces/SBogers10/umans.komma.pro/app/Komma/Navigation/NavigationComposer.php
<?php
namespace Komma\Navigation;
use Komma\Pages\PageService;
class NavigationComposer
{
protected $pageService;
protected $simplePageService;
/**
* FooterComposer constructor.
* @param PageService $pageService
*/
public function __construct()
{
$pageService = \App::make('Komma\Pages\PageService');
$this->pageService = $pageService;
}
/**
* Order navigation by given structure
*
* @param array $order
* @param array $collection
*/
public function orderNavigationByStructure(Array $order, Array $collection){
$navigation = [];
//Loop through the collection
foreach ($collection as $navSet){
//loop trough the given sets for the navigation items
foreach ($navSet as $item){
//look the key with the same code_name in the order
$key = array_search($item->code_name, $order);
if(in_array($item->code_name, ['exterior', 'cavity_wall'])){
$item = (object)['name' => 'Home','route' => $item->route,'code_name' => $item->code_name];
}
//add navigation item in the key of the order
$navigation[$key] = $item;
}
}
//sort navigation on key order
ksort($navigation);
return $navigation;
}
}