public function build($widgets, string $widgetGroup = '', array $widgetId = [])
    {
        // Without Widgets
        if (!$widgets) {
            return $widgets;
        }

        // Load User Widget Configuration
        $this->loadUserConfig();

        // Output Widgets
        $outputWidget = [];

        // Custom Items
        if ($widgetId) {
            foreach ($widgetId as $id) {
                if (isset($widgets[$id])) {
                    // Activate
                    $widgets[$id]->setActive($this->widgetConfig[$widget->getId()]['status'] ?? false);

                    // Set Widget Config
                    $widgets[$id]->setConfig($this->widgetConfig[$widget->getId()] ?? []);

                    $outputWidget[] = $widgets[$id];
                }
            }

            return $outputWidget;
        }

        foreach ($widgets as $widget) {
            if ('' !== $widgetGroup && $widget->getGroup() !== $widgetGroup) {
                continue;
            }

            // Set Custom Order
            if (isset($this->widgetConfig[$widget->getId()]['order'])) {
                $widget->setOrder($this->widgetConfig[$widget->getId()]['order']);
            }

            // Order
            if (null !== $widget->getOrder()) {
                while (isset($outputWidget[$widget->getOrder()])) {
                    $widget->setOrder($widget->getOrder() + 1);
                }

                $outputWidget[$widget->getOrder()] = $widget;
            } else {
                $outputWidget[] = $widget;
            }

            // Activate
            $widget->setActive($this->widgetConfig[$widget->getId()]['status'] ?? false);

            // Set Widget Config
            $widget->setConfig($this->widgetConfig[$widget->getId()] ?? []);
        }

        // Sort
        ksort($outputWidget);

        return $outputWidget;
    }
public function build($widgets, string $widgetGroup = '', array $widgetId = [])
    {
        // Without Widgets
        if (!$widgets) {
            return $widgets;
        }

        // Load User Widget Configuration
        $this->loadUserConfig();

        // Output Widgets
        $outputWidget = [];

        // Custom Items
        if ($widgetId) {
            foreach ($widgetId as $id) {
                if (isset($widgets[$id])) {
                    // Activate
                    $widgets[$id]->setActive($this->widgetConfig[$widget->getId()]['status'] ?? false);

                    // Set Widget Config
                    $widgets[$id]->setConfig($this->widgetConfig[$widget->getId()] ?? []);

                    $outputWidget[] = $widgets[$id];
                }
            }

            return $outputWidget;
        }

        foreach ($widgets as $widget) {
            if ('' !== $widgetGroup && $widget->getGroup() !== $widgetGroup) {
                continue;
            }

            // Set Custom Order
            if (isset($this->widgetConfig[$widget->getId()]['order'])) {
                $widget->setOrder($this->widgetConfig[$widget->getId()]['order']);
            }

            // Order
            if (null !== $widget->getOrder()) {
                while (isset($outputWidget[$widget->getOrder()])) {
                    $widget->setOrder($widget->getOrder() + 1);
                }

                $outputWidget[$widget->getOrder()] = $widget;
            } else {
                $outputWidget[] = $widget;
            }

            // Activate
            $widget->setActive($this->widgetConfig[$widget->getId()]['status'] ?? false);

            // Set Widget Config
            $widget->setConfig($this->widgetConfig[$widget->getId()] ?? []);
        }

        // Sort
        ksort($outputWidget);

        return $outputWidget;
    }
public function build ( $ widgets , string $ widgetGroup = '' , array $ widgetId = [ ] ) { // Without Widgets if ( ! $ widgets ) { return $ widgets ; } // Load User Widget Configuration $ this -> loadUserConfig ( ) ; // Output Widgets $ outputWidget = [ ] ; // Custom Items if ( $ widgetId ) { foreach ( $ widgetId as $ id ) { if ( isset ( $ widgets [ $ id ] ) ) { // Activate $ widgets [ $ id ] -> setActive ( $ this -> widgetConfig [ $ widget -> getId ( ) ] [ 'status' ] ?? false ) ; // Set Widget Config $ widgets [ $ id ] -> setConfig ( $ this -> widgetConfig [ $ widget -> getId ( ) ] ?? [ ] ) ; $ outputWidget [ ] = $ widgets [ $ id ] ; } } return $ outputWidget ; } foreach ( $ widgets as $ widget ) { if ( '' !== $ widgetGroup && $ widget -> getGroup ( ) !== $ widgetGroup ) { continue ; } // Set Custom Order if ( isset ( $ this -> widgetConfig [ $ widget -> getId ( ) ] [ 'order' ] ) ) { $ widget -> setOrder ( $ this -> widgetConfig [ $ widget -> getId ( ) ] [ 'order' ] ) ; } // Order if ( null !== $ widget -> getOrder ( ) ) { while ( isset ( $ outputWidget [ $ widget -> getOrder ( ) ] ) ) { $ widget -> setOrder ( $ widget -> getOrder ( ) + 1 ) ; } $ outputWidget [ $ widget -> getOrder ( ) ] = $ widget ; } else { $ outputWidget [ ] = $ widget ; } // Activate $ widget -> setActive ( $ this -> widgetConfig [ $ widget -> getId ( ) ] [ 'status' ] ?? false ) ; // Set Widget Config $ widget -> setConfig ( $ this -> widgetConfig [ $ widget -> getId ( ) ] ?? [ ] ) ; } // Sort ksort ( $ outputWidget ) ; return $ outputWidget ; }
Build Widgets.

@param $widgets ItemInterface[]
@param string $widgetGroup
@param array  $widgetId

@return ItemInterface[]
Build Widgets .