/**
  * {@inheritdoc}
  */
 public function getWidgets($object)
 {
     $result = [];
     $entityClass = ClassUtils::getClass($object);
     $items = $this->activityManager->getActivityActions($entityClass);
     foreach ($items as $item) {
         $buttonWidget = $this->placeholderProvider->getItem($item['button_widget'], ['entity' => $object]);
         if ($buttonWidget) {
             $widget = ['name' => $item['button_widget'], 'button' => $buttonWidget];
             if (!empty($item['link_widget'])) {
                 $linkWidget = $this->placeholderProvider->getItem($item['link_widget'], ['entity' => $object]);
                 if ($linkWidget) {
                     $widget['link'] = $linkWidget;
                 }
             }
             if (isset($item['group'])) {
                 $widget['group'] = $item['group'];
             }
             if (isset($item['priority'])) {
                 $widget['priority'] = $item['priority'];
             }
             $result[] = $widget;
         }
     }
     return $result;
 }
 /**
  * Test that activity action is not returned id activity is enabled on UI but schema update is not performed yet
  */
 public function testGetActivityActionsNoSchemaUpdate()
 {
     $targetEntityClass = 'Test\\Entity';
     $activityClass = 'Test\\Activity';
     $targetEntityActivityConfig = new Config(new EntityConfigId('activity', $targetEntityClass));
     $targetEntityActivityConfig->set('activities', [$activityClass]);
     $activityExtendConfig = new Config(new EntityConfigId('extend', $activityClass));
     $activityExtendConfig->set('relation', []);
     $this->activityConfigProvider->expects($this->once())->method('getConfig')->with($targetEntityClass, null)->will($this->returnValue($targetEntityActivityConfig));
     $this->extendConfigProvider->expects($this->once())->method('getConfig')->with($activityClass, null)->will($this->returnValue($activityExtendConfig));
     $this->entityConfigProvider->expects($this->never())->method('getConfig');
     $this->assertEquals([], $this->manager->getActivityActions($targetEntityClass));
 }
 /**
  * Test that activity action is not returned if an activity is enabled on UI but schema update is not performed yet
  */
 public function testGetActivityActionsNoSchemaUpdate()
 {
     $targetEntityClass = 'Test\\Entity';
     $activityClass = 'Test\\Activity';
     $targetEntityActivityConfig = new Config(new EntityConfigId('activity', $targetEntityClass));
     $targetEntityActivityConfig->set('activities', [$activityClass]);
     $activityAssociationName = ExtendHelper::buildAssociationName($targetEntityClass, ActivityScope::ASSOCIATION_KIND);
     $activityAssociationConfig = new Config(new FieldConfigId('extend', $activityClass, $activityAssociationName));
     $activityAssociationConfig->set('is_extend', true);
     $activityAssociationConfig->set('state', ExtendScope::STATE_NEW);
     $this->activityConfigProvider->expects($this->once())->method('getConfig')->with($targetEntityClass, null)->will($this->returnValue($targetEntityActivityConfig));
     $this->extendConfigProvider->expects($this->once())->method('hasConfig')->with($activityClass, $activityAssociationName)->will($this->returnValue(true));
     $this->extendConfigProvider->expects($this->once())->method('getConfig')->with($activityClass, $activityAssociationName)->will($this->returnValue($activityAssociationConfig));
     $this->entityConfigProvider->expects($this->never())->method('getConfig');
     $this->assertEquals([], $this->manager->getActivityActions($targetEntityClass));
 }