HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/zuiderbos.komma.pro/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);

                //add navigation item in the key of the order
                $navigation[$key] = $item;
            }
        }
        //sort navigation on key order
        ksort($navigation);

        return $navigation;
    }

}