Bundle/WidgetMapBundle/Builder/WidgetMapBuilder.php
protected function orderizeWidgetMap(WidgetMap $currentWidgetMap, $builtWidgetMap, $slot, $slotWidgetMaps, View $view)
    {
        $children = $this->resolver->getChildren($currentWidgetMap, $view);
        foreach ($children as $child) {
            // check if the founded child belongs to the view
            if (in_array($child, $slotWidgetMaps, true)) {
                // Find the position of the "currentWidgetMap" inside the builtWidgetMap,
                // add "1" to this position if wanted position is "after", 0 is it's before.
                $offset = array_search($currentWidgetMap, $builtWidgetMap[$slot]) + ($child->getPosition() == WidgetMap::POSITION_AFTER ? 1 : 0);
                // insert the child in builtWidgetMap at offset position
                array_splice($builtWidgetMap[$slot], $offset, 0, [$child]);
                // call myself with child
                $builtWidgetMap = $this->orderizeWidgetMap($child, $builtWidgetMap, $slot, $slotWidgetMaps, $view);
            }
        }

        return $builtWidgetMap;
    }
protected function orderizeWidgetMap(WidgetMap $currentWidgetMap, $builtWidgetMap, $slot, $slotWidgetMaps, View $view)
    {
        $children = $this->resolver->getChildren($currentWidgetMap, $view);
        foreach ($children as $child) {
            // check if the founded child belongs to the view
            if (in_array($child, $slotWidgetMaps, true)) {
                // Find the position of the "currentWidgetMap" inside the builtWidgetMap,
                // add "1" to this position if wanted position is "after", 0 is it's before.
                $offset = array_search($currentWidgetMap, $builtWidgetMap[$slot]) + ($child->getPosition() == WidgetMap::POSITION_AFTER ? 1 : 0);
                // insert the child in builtWidgetMap at offset position
                array_splice($builtWidgetMap[$slot], $offset, 0, [$child]);
                // call myself with child
                $builtWidgetMap = $this->orderizeWidgetMap($child, $builtWidgetMap, $slot, $slotWidgetMaps, $view);
            }
        }

        return $builtWidgetMap;
    }
protected function orderizeWidgetMap ( WidgetMap $ currentWidgetMap , $ builtWidgetMap , $ slot , $ slotWidgetMaps , View $ view ) { $ children = $ this -> resolver -> getChildren ( $ currentWidgetMap , $ view ) ; foreach ( $ children as $ child ) { // check if the founded child belongs to the view if ( in_array ( $ child , $ slotWidgetMaps , true ) ) { // Find the position of the "currentWidgetMap" inside the builtWidgetMap, // add "1" to this position if wanted position is "after", 0 is it's before. $ offset = array_search ( $ currentWidgetMap , $ builtWidgetMap [ $ slot ] ) + ( $ child -> getPosition ( ) == WidgetMap :: POSITION_AFTER ? 1 : 0 ) ; // insert the child in builtWidgetMap at offset position array_splice ( $ builtWidgetMap [ $ slot ] , $ offset , 0 , [ $ child ] ) ; // call myself with child $ builtWidgetMap = $ this -> orderizeWidgetMap ( $ child , $ builtWidgetMap , $ slot , $ slotWidgetMaps , $ view ) ; } } return $ builtWidgetMap ; }
Get the children of given WidgetMap and place them recursively in the "builtWidgetMap" array at the right place
depending of the children parents and positions.

@param WidgetMap $currentWidgetMap
@param $builtWidgetMap
@param $slot
@param $slotWidgetMaps
@param View $view

@return mixed
Get the children of given WidgetMap and place them recursively in the builtWidgetMap array at the right place depending of the children parents and positions .