/** * {@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); }
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()); }
/** * 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); } }