示例#1
0
 /**
  * {@inheritdoc}
  */
 protected function doInitialize()
 {
     $widgets = array();
     /** @var Widget $widget */
     foreach ($this->dashboard->getWidgets() as $widget) {
         $widgets[] = $this->factory->createWidgetModel($widget);
     }
     $this->collection = new ArrayCollection($widgets);
 }
示例#2
0
 public function testAddAndResetWidgets()
 {
     $widget = $this->getMock('Oro\\Bundle\\DashboardBundle\\Entity\\Widget');
     $widget->expects($this->once())->method('setDashboard')->with($this->dashboard);
     $this->assertFalse($this->dashboard->getWidgets()->contains($widget));
     $this->assertEquals($this->dashboard, $this->dashboard->addWidget($widget));
     $this->assertEquals(1, $this->dashboard->getWidgets()->count());
     $this->assertTrue($this->dashboard->getWidgets()->contains($widget));
     $this->dashboard->resetWidgets();
     $this->assertEquals(0, $this->dashboard->getWidgets()->count());
 }
示例#3
0
 /**
  * Copy widgets from source entity to dashboard model
  *
  * @param DashboardModel $target
  * @param Dashboard      $source
  */
 protected function copyWidgets(DashboardModel $target, Dashboard $source)
 {
     foreach ($source->getWidgets() as $sourceWidget) {
         $widgetModel = $this->copyWidgetModel($sourceWidget);
         $this->save($widgetModel, false);
         $target->addWidget($widgetModel);
     }
 }