public function composeWidgets(array $widgetsData): array
    {
        $container = clone $this->container;
        unset($container->widget);
        unset($container->widgets);
        unset($container->model);
        
        $widgetsResults = [];
        
        foreach ($widgetsData as $place => $placeWidgets) {
            $results = [];
            
            foreach ($placeWidgets as $widget) {
                if (
                    !($widget instanceof Widget) 
                    || empty($widget->vendor) 
                    || (empty($widget->module) && empty($widget->name))
                ) {
                    continue;
                }
                
                if (empty($widget->module)) {
                    $widgetControllerClass = 
                        '\Ufo\Modules' . 
                        '\\' . ucfirst($widget->vendor) . 
                        '\Widgets' . 
                        '\\' . ucfirst($widget->name) . 
                        '\Controller';
                } else {
                    $widgetControllerClass = 
                        '\Ufo\Modules' . 
                        '\\' . ucfirst($widget->vendor) . 
                        '\\' . ucfirst($widget->module) . 
                        '\Widget' . ucfirst($widget->name) . 'Controller';
                }
                
                $container->set('widget', $widget);
                $container->set('data', get_object_vars($widget));
                
                if (class_exists($widgetControllerClass)) {
                    $widgetController = new $widgetControllerClass();
                    if ($widgetController instanceof DIObjectInterface) {
                        $widgetController->inject($container);
                    }
                    $results[] = $widgetController->compose();
                    
                } else {
                    $defaultControllerClass = '\Ufo\Modules\Controller'; //defaultController
                    
                    $defaultController = new $defaultControllerClass();
                    $defaultController->inject($container);
                    $result = $defaultController->compose();
                    
                    $result->getView()->setTemplate($this->config->templateWidget); //change default template
                    $results[] = $result;
                }
            }
            
            $view = new View($this->config->templateWidgets, ['widgets' => $results]);
            $view->inject($this->container);
            $widgetsResults[$place] = $view;
        }
        
        return $widgetsResults;
    }
public function composeWidgets(array $widgetsData): array
    {
        $container = clone $this->container;
        unset($container->widget);
        unset($container->widgets);
        unset($container->model);
        
        $widgetsResults = [];
        
        foreach ($widgetsData as $place => $placeWidgets) {
            $results = [];
            
            foreach ($placeWidgets as $widget) {
                if (
                    !($widget instanceof Widget) 
                    || empty($widget->vendor) 
                    || (empty($widget->module) && empty($widget->name))
                ) {
                    continue;
                }
                
                if (empty($widget->module)) {
                    $widgetControllerClass = 
                        '\Ufo\Modules' . 
                        '\\' . ucfirst($widget->vendor) . 
                        '\Widgets' . 
                        '\\' . ucfirst($widget->name) . 
                        '\Controller';
                } else {
                    $widgetControllerClass = 
                        '\Ufo\Modules' . 
                        '\\' . ucfirst($widget->vendor) . 
                        '\\' . ucfirst($widget->module) . 
                        '\Widget' . ucfirst($widget->name) . 'Controller';
                }
                
                $container->set('widget', $widget);
                $container->set('data', get_object_vars($widget));
                
                if (class_exists($widgetControllerClass)) {
                    $widgetController = new $widgetControllerClass();
                    if ($widgetController instanceof DIObjectInterface) {
                        $widgetController->inject($container);
                    }
                    $results[] = $widgetController->compose();
                    
                } else {
                    $defaultControllerClass = '\Ufo\Modules\Controller'; //defaultController
                    
                    $defaultController = new $defaultControllerClass();
                    $defaultController->inject($container);
                    $result = $defaultController->compose();
                    
                    $result->getView()->setTemplate($this->config->templateWidget); //change default template
                    $results[] = $result;
                }
            }
            
            $view = new View($this->config->templateWidgets, ['widgets' => $results]);
            $view->inject($this->container);
            $widgetsResults[$place] = $view;
        }
        
        return $widgetsResults;
    }
public function composeWidgets ( array $ widgetsData ) : array { $ container = clone $ this -> container ; unset ( $ container -> widget ) ; unset ( $ container -> widgets ) ; unset ( $ container -> model ) ; $ widgetsResults = [ ] ; foreach ( $ widgetsData as $ place => $ placeWidgets ) { $ results = [ ] ; foreach ( $ placeWidgets as $ widget ) { if ( ! ( $ widget instanceof Widget ) || empty ( $ widget -> vendor ) || ( empty ( $ widget -> module ) && empty ( $ widget -> name ) ) ) { continue ; } if ( empty ( $ widget -> module ) ) { $ widgetControllerClass = '\Ufo\Modules' . '\\' . ucfirst ( $ widget -> vendor ) . '\Widgets' . '\\' . ucfirst ( $ widget -> name ) . '\Controller' ; } else { $ widgetControllerClass = '\Ufo\Modules' . '\\' . ucfirst ( $ widget -> vendor ) . '\\' . ucfirst ( $ widget -> module ) . '\Widget' . ucfirst ( $ widget -> name ) . 'Controller' ; } $ container -> set ( 'widget' , $ widget ) ; $ container -> set ( 'data' , get_object_vars ( $ widget ) ) ; if ( class_exists ( $ widgetControllerClass ) ) { $ widgetController = new $ widgetControllerClass ( ) ; if ( $ widgetController instanceof DIObjectInterface ) { $ widgetController -> inject ( $ container ) ; } $ results [ ] = $ widgetController -> compose ( ) ; } else { $ defaultControllerClass = '\Ufo\Modules\Controller' ; //defaultController $ defaultController = new $ defaultControllerClass ( ) ; $ defaultController -> inject ( $ container ) ; $ result = $ defaultController -> compose ( ) ; $ result -> getView ( ) -> setTemplate ( $ this -> config -> templateWidget ) ; //change default template $ results [ ] = $ result ; } } $ view = new View ( $ this -> config -> templateWidgets , [ 'widgets' => $ results ] ) ; $ view -> inject ( $ this -> container ) ; $ widgetsResults [ $ place ] = $ view ; } return $ widgetsResults ; }
Create object for each widgets data item.
@param array $widgetsData
@return array
Create object for each widgets data item .