/**
  * {@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;
 }
 /**
  * {@inheritdoc}
  */
 public function getWidgets($object)
 {
     $result = [];
     $buttonWidget = $this->placeholderProvider->getItem($this->buttonWidgetName, ['entity' => $object]);
     if ($buttonWidget) {
         $widget['name'] = $this->buttonWidgetName;
         $widget['button'] = $buttonWidget;
         if (!empty($this->linkWidgetName)) {
             $linkWidget = $this->placeholderProvider->getItem($this->linkWidgetName, ['entity' => $object]);
             if ($linkWidget) {
                 $widget['link'] = $linkWidget;
             }
         }
         $result[] = $widget;
     }
     return $result;
 }
Пример #3
0
 /**
  * @param string $name
  * @param array  $variables
  * @return array
  */
 protected function getPlaceholderData($name, $variables)
 {
     $result = array();
     $items = $this->placeholder->getPlaceholderItems($name, $variables);
     foreach ($items as $item) {
         $result[] = $this->renderItemContent($item, $variables);
     }
     return $result;
 }
Пример #4
0
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testGetPlaceholderItems()
 {
     $placeholderName = 'test_placeholder';
     $variables = ['foo' => 'bar'];
     $items = $this->placeholders['items'];
     $index = 0;
     $isGrantedIndex = 0;
     // item1
     $this->resolver->expects($this->at($index++))->method('resolve')->with($items['item1'], $variables)->will($this->returnValue($items['item1']));
     // item2
     $this->resolver->expects($this->at($index++))->method('resolve')->with(['applicable' => $items['item2']['applicable']], $variables)->will($this->returnValue(['applicable' => true]));
     unset($items['item2']['applicable']);
     $this->resolver->expects($this->at($index++))->method('resolve')->with($items['item2'], $variables)->will($this->returnValue($items['item2']));
     // item3
     $this->resolver->expects($this->at($index++))->method('resolve')->with(['applicable' => $items['item3']['applicable']], $variables)->will($this->returnValue(['applicable' => false]));
     // item4
     $this->resolver->expects($this->at($index++))->method('resolve')->with(['applicable' => $items['item4']['applicable']], $variables)->will($this->returnValue(['applicable' => $items['item4']['applicable']]));
     unset($items['item4']['applicable']);
     $this->resolver->expects($this->at($index++))->method('resolve')->with($items['item4'], $variables)->will($this->returnValue($items['item4']));
     // item5
     $this->resolver->expects($this->at($index++))->method('resolve')->with(['applicable' => $items['item5']['applicable']], $variables)->will($this->returnValue(['applicable' => $items['item5']['applicable']]));
     // item6
     $this->securityFacade->expects($this->at($isGrantedIndex++))->method('isGranted')->with('acl_ancestor')->will($this->returnValue(false));
     // item7
     $this->securityFacade->expects($this->at($isGrantedIndex++))->method('isGranted')->with('acl_ancestor')->will($this->returnValue(true));
     unset($items['item7']['acl']);
     $this->resolver->expects($this->at($index++))->method('resolve')->with($items['item7'], $variables)->will($this->returnValue($items['item7']));
     // item8
     $this->securityFacade->expects($this->at($isGrantedIndex++))->method('isGranted')->with('acl_ancestor1')->will($this->returnValue(true));
     $this->securityFacade->expects($this->at($isGrantedIndex++))->method('isGranted')->with('acl_ancestor2')->will($this->returnValue(true));
     unset($items['item8']['acl']);
     $this->resolver->expects($this->at($index++))->method('resolve')->with($items['item8'], $variables)->will($this->returnValue($items['item8']));
     // item9
     $this->securityFacade->expects($this->at($isGrantedIndex++))->method('isGranted')->with('acl_ancestor1')->will($this->returnValue(true));
     $this->securityFacade->expects($this->at($isGrantedIndex++))->method('isGranted')->with('acl_ancestor2')->will($this->returnValue(false));
     $expected = [$items['item1'], $items['item2'], $items['item4'], $items['item7'], $items['item8']];
     $this->assertEquals($expected, $this->provider->getPlaceholderItems($placeholderName, $variables));
 }