public function testName() { $this->assertNull($this->widget->getName()); $value = 'test'; $this->assertEquals($this->widget, $this->widget->setName($value)); $this->assertEquals($value, $this->widget->getName()); }
/** * @Route("/configure/{id}", name="oro_dashboard_configure", requirements={"id"="\d+"}) * @Method({"GET", "POST"}) * @Template("OroDashboardBundle:Dashboard:dialog/configure.html.twig") */ public function configureAction(Request $request, Widget $widget) { if (!$this->getSecurityFacade()->isGranted('EDIT', $widget->getDashboard())) { throw new AccessDeniedException(); } $form = $this->getFormProvider()->getForm($widget->getName()); $saved = false; $form->setData($this->get('oro_dashboard.widget_configs')->getFormValues($widget)); $form->handleRequest($request); if ($form->isValid()) { $widget->setOptions($form->getData()); $this->getEntityManager()->flush(); $saved = true; } return ['form' => $form->createView(), 'formAction' => $request->getRequestUri(), 'saved' => $saved]; }
/** * @param Widget $widget * @return array */ public function getFormValues(Widget $widget) { $options = $widget->getOptions(); $widgetConfig = $this->configProvider->getWidgetConfig($widget->getName()); foreach ($widgetConfig['configuration'] as $name => $config) { $value = isset($options[$name]) ? $options[$name] : null; $options[$name] = $this->valueProvider->getFormValue($config['type'], $config, $value); } $options = $this->loadDefaultValue($options, $widgetConfig); return $options; }
/** * Copy widget model by entity * * @param Widget $sourceWidget * * @return WidgetModel */ protected function copyWidgetModel(Widget $sourceWidget) { $widget = new Widget(); $widget->setLayoutPosition($sourceWidget->getLayoutPosition()); $widget->setName($sourceWidget->getName()); return $this->getWidgetModel($widget); }
/** * @param Widget $widget * @return WidgetModel */ public function createWidgetModel(Widget $widget) { $widgetConfig = $this->configProvider->getWidgetConfig($widget->getName()); $widgetState = $this->stateManager->getWidgetState($widget); return new WidgetModel($widget, $widgetConfig, $widgetState); }