/** * {@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); }
/** * Get dashboard model from dashboard entity * * @param Dashboard $dashboard * @return DashboardModel */ public function createDashboardModel(Dashboard $dashboard) { $dashboardName = $dashboard->getName(); if (!empty($dashboardName)) { $dashboardConfig = $this->configProvider->getDashboardConfig($dashboardName); } else { $dashboardConfig = array(); } return new DashboardModel($dashboard, $this->createWidgetCollection($dashboard), $dashboardConfig); }
public function testDelete() { $id = $this->dashboard->getId(); $this->client->request('DELETE', $this->getUrl('oro_api_delete_dashboard', ['id' => $id])); $result = $this->client->getResponse(); $this->assertEmptyResponseStatusCodeEquals($result, 204); $this->client->request('DELETE', $this->getUrl('oro_api_delete_dashboard', ['id' => $id])); $result = $this->client->getResponse(); $this->assertJsonResponseStatusCodeEquals($result, 404); }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $dashboard = new Dashboard(); $dashboard->setName('TestWidgets')->setLabel('TestWidgets')->setIsDefault(false); $manager->persist($dashboard); $averageOrderAmountChart = new Widget(); $averageOrderAmountChart->setDashboard($dashboard)->setName('average_order_amount_chart')->setLayoutPosition([1, 0]); $newMagentoCustomersChart = new Widget(); $newMagentoCustomersChart->setDashboard($dashboard)->setName('new_magento_customers_chart')->setLayoutPosition([0, 1]); $manager->persist($dashboard); $manager->persist($averageOrderAmountChart); $manager->persist($newMagentoCustomersChart); $manager->flush(); }
/** * @param string $name * @param array $layoutPositions * @return Widget */ protected function createWidget($name = 'quick_launchpad', array $layoutPositions = [1, 1]) { $dashboard = new Dashboard(); $dashboard->setName('main'); $widget = new Widget(); $widget->setName($name)->setLayoutPosition($layoutPositions)->setDashboard($dashboard); $dashboard->addWidget($widget); return $widget; }
public function testPreUpdate() { $this->assertNull($this->dashboard->getUpdatedAt()); $this->dashboard->preUpdate(); $this->assertInstanceOf('\\DateTime', $this->dashboard->getUpdatedAt()); }
/** * Get dashboard organization * * @return User */ public function getOrganization() { return $this->entity->getOrganization(); }
/** * 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); } }