コード例 #1
0
 /**
  * Processes the widgets of a section to make them ready for usage
  * @param \ride\library\cms\node\Node $node Instance of the node
  * @param string $region Name of the region
  * @param string $section Name of the section
  * @param array $availableWidgets Array with the id of a widget instance as
  * key and the dependency id as value
  * @param array $widgets Array for the resulting widgets. The key will be
  * the id of the block, the value an array with the widget id as key and the
  * widget instance as value
  * @param array $inheritedWidgets Array with structure of the $widgets var
  * indicating which widgets are inherited, value in the block array is a
  * widget id and not a widget instance
  * @return null
  */
 protected function processSectionWidgets(Node $node, $locale, $region, $section, array $availableWidgets, array &$widgets, array &$inheritedWidgets)
 {
     $inheritedSectionWidgets = $node->getInheritedWidgets($region, $section);
     $sectionWidgets = $node->getWidgets($region, $section);
     foreach ($sectionWidgets as $block => $blockWidgets) {
         $widgets[$block] = array();
         $inheritedWidgets[$block] = array();
         foreach ($blockWidgets as $widgetId => $widget) {
             if (!$widget || !isset($availableWidgets[$widget])) {
                 continue;
             }
             $widget = clone $availableWidgets[$widget];
             $widget->setIdentifier($widgetId);
             $widget->setProperties($node->getWidgetProperties($widgetId));
             $widget->setLocale($locale);
             if ($widget instanceof AbstractController) {
                 $widget->setConfig($this->config);
                 $widget->setDependencyInjector($this->dependencyInjector);
             }
             $widgets[$block][$widgetId] = $widget;
             if (isset($inheritedSectionWidgets[$block][$widgetId])) {
                 $inheritedWidgets[$block][$widgetId] = $widgetId;
             }
         }
     }
 }