/**
  * {@inheritdoc}
  *
  * The format of returning array:
  *      [group name] =>
  *          'widgets' => array
  */
 public function getWidgets($object)
 {
     $widgets = $this->getWidgetsOrderedByPriority($object);
     if ($this->eventDispatcher) {
         $beforeGroupingChainWidgetEvent = new BeforeGroupingChainWidgetEvent($this->pageType, $widgets, $object);
         $this->eventDispatcher->dispatch(Events::BEFORE_GROUPING_CHAIN_WIDGET, $beforeGroupingChainWidgetEvent);
         $widgets = $beforeGroupingChainWidgetEvent->getWidgets();
     }
     $result = [];
     foreach ($widgets as $widget) {
         if (isset($widget['group'])) {
             $groupName = $widget['group'];
             unset($widget['group']);
         } else {
             $groupName = '';
         }
         if (!isset($result[$groupName])) {
             $result[$groupName] = ['widgets' => []];
             if ($this->groupNameProvider && !empty($groupName)) {
                 $result[$groupName]['label'] = $this->groupNameProvider->getLabel(['groupName' => $groupName, 'entityClass' => ClassUtils::getClass($object)]);
             }
         }
         $result[$groupName]['widgets'][] = $widget;
     }
     return $result;
 }
 /**
  * {@inheritdoc}
  *
  * The format of returning array:
  *      [group name] =>
  *          'widgets' => array
  */
 public function getWidgets($object)
 {
     $widgets = $this->getWidgetsOrderedByPriority($object);
     $result = [];
     foreach ($widgets as $widget) {
         if (isset($widget['group'])) {
             $groupName = $widget['group'];
             unset($widget['group']);
         } else {
             $groupName = '';
         }
         if (!isset($result[$groupName])) {
             $result[$groupName] = ['widgets' => []];
             if ($this->groupNameProvider && !empty($groupName)) {
                 $result[$groupName]['label'] = $this->groupNameProvider->getLabel(['groupName' => $groupName, 'entityClass' => ClassUtils::getClass($object)]);
             }
         }
         $result[$groupName]['widgets'][] = $widget;
     }
     return $result;
 }